Skip to content

Saleor Core: the high performance, composable, headless commerce API.

get_thumbnail should not decide what method to use

NyanKiyoshi790235d38b6c
diff --git a/saleor/core/management/commands/create_thumbnails.py b/saleor/core/management/commands/create_thumbnails.py
index 7ca4a08a44..fc532aa5e0 100644
--- a/saleor/core/management/commands/create_thumbnails.py
+++ b/saleor/core/management/commands/create_thumbnails.py
@@ -9,13 +9,13 @@ logger = logging.getLogger(__name__)
class Command(BaseCommand):
- help = 'Generate thumbanails for all images'
+ help = 'Generate thumbnails for all images'
def handle(self, *args, **options):
self.warm_products()
def warm_products(self):
- self.stdout.write('Products thumbanails generation:')
+ self.stdout.write('Products thumbnails generation:')
warmer = VersatileImageFieldWarmer(
instance_or_queryset=ProductImage.objects.all(),
rendition_key_set='products', image_attr='image', verbose=True)
diff --git a/saleor/product/templatetags/product_images.py b/saleor/product/templatetags/product_images.py
index 3f43daddd7..3145c92549 100644
--- a/saleor/product/templatetags/product_images.py
+++ b/saleor/product/templatetags/product_images.py
@@ -51,16 +51,13 @@ def get_thumbnail(instance, size, method='crop'):
on_demand = settings.VERSATILEIMAGEFIELD_SETTINGS[
'create_images_on_demand']
if instance:
- if (size_name not in AVAILABLE_SIZES and not on_demand):
+ if size_name not in AVAILABLE_SIZES and not on_demand:
msg = (
"Thumbnail size %s is not defined in settings "
"and it won't be generated automatically" % size_name)
warnings.warn(msg)
try:
- if method == 'crop':
- thumbnail = instance.crop[size]
- else:
- thumbnail = instance.thumbnail[size]
+ thumbnail = getattr(instance, method)[size]
except Exception:
logger.exception(
'Thumbnail fetch failed',