【发布时间】:2021-05-15 11:50:24
【问题描述】:
我在此模型中使用简单缩略图图像裁剪应用程序和别名(简化):
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。
就像它为空别名生成一个额外的缩略图,但我在我的代码中找不到任何可以做到这一点的东西。
有什么想法吗?
【问题讨论】: