【问题标题】:Extra alias thumbnail generated生成了额外的别名缩略图
【发布时间】: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。
就像它为空别名生成一个额外的缩略图,但我在我的代码中找不到任何可以做到这一点的东西。
有什么想法吗?

【问题讨论】:

    标签: django easy-thumbnails


    【解决方案1】:

    好的,我想我找到了答案。 图片裁剪应用需要创建缩略图,以允许用户在后台调整裁剪区域并动态创建;它仅在用户与管理员交互时生成,这就是我的情况。

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-07
      • 2020-01-30
      • 2012-09-01
      相关资源
      最近更新 更多