Extra alias thumbnail generated

286 views Asked by At

I am using easy-thumbnails the image-cropping app and aliases in this model (simplified):

from image_cropping import ImageRatioField
from easy_thumbnails.fields import ThumbnailerImageField

class Image(SlugMixin, models.Model):
    slug_from_field = 'title'
    slug_length = 110

    image = ThumbnailerImageField('path', upload_to=get_file_name,
                                  resize_source=dict(
                                      size=(1600, 0), quality=95),
                                  width_field='width', height_field='height',
                                  blank=True, null=True)
    crop_thumb = ImageRatioField(
      'image', '120x90',
      help_text='Drag the handles and crop area to crop the image.',
      verbose_name="crop thumbnail")
    crop_image = ImageRatioField(
      'image', '400x300',
      free_crop=True,
      help_text='Drag the handles and crop area to crop the image.')
    ....

The alias definition in settings.py:

THUMBNAIL_ALIASES = {
    '': {
        'small': {
            'size': (120, 90), 'detail': True, 'crop': True, 'upscale': True,
            'ALIAS': 'small', 'ratio_field': 'crop_thumb',
        },
        'medium': {
            'size': (240, 180), 'detail': True, 'crop': True, 'upscale': True,
            'ALIAS': 'medium', 'ratio_field': 'crop_thumb',
        },
        'large': {
            'size': (0, 400), 'quality': 90, 'detail': True, 'upscale': True,
            'ALIAS': 'large', 'ratio_field': 'crop_image',
        },
    },
}

THUMBNAIL_NAMER = 'easy_thumbnails.namers.alias'

I am expecting to get 3 thumbnails per image uploaded, but I am getting 4. The 3 expected are named my_image.jpg.small.jpg + medium and large and the additional one is my_image.jpg..jpg and is 300px wide.
It is like it generates an extra thumbnail for an empty alias, but I cannot find anything in my code that would do this.
Any idea?

1

There are 1 answers

0
jphilip On

OK, I think I found the answer. The image-cropping app needs to create a thumbnail to allow the user to adjust the cropping region in the admin and dynamically creates it; it is only generated when the user interacts in with admin which is what happens in my case.