Resolve scope in thumbnail function calls in layers/models.py