我在此模型中使用简单缩略图图像裁剪应用程序和别名(简化):
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.')
....
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'
我预计每张上传的图像会得到 3 个缩略图,但我得到了 4 个。预期的 3 个被命名为 my_image.jpg.small.jpg + medium 和 large,另外一个是 my_image.jpg..jpg 并且是 300px 宽。
就像它为空别名生成一个额外的缩略图,但我在我的代码中找不到任何可以做到这一点的东西。
任何想法?