首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >blueimp文件上传器image_versions不工作

blueimp文件上传器image_versions不工作
EN

Stack Overflow用户
提问于 2015-01-15 16:19:45
回答 1查看 645关注 0票数 3

我已经上传了blueimp文件。我试着制造更多的image_versions。第一个和最后一个image_version确实可以工作。在我的例子“”,“小”和“缩略图”工作,另一个不起作用。在另一个image_versions中,图像将被上传,但不会调整到合适的大小。

这是我的代码片段:

代码语言:javascript
复制
'image_versions' => array(
            // The empty image version key defines options for the original image:
            '' => array(
                // Automatically rotate images based on EXIF meta data:
                'auto_orient' => true
            ),
            'small' => array(
                'max_width' => 150,
                'max_height' => 150
            ),

            'medium' => array(
                'max_width' => 200,
                'max_height' => 200
            ),

            'large' => array(
                'max_width' => 400,
                'max_height' => 400
            ),

            'xlarge' => array(
                'max_width' => 600,
                'max_height' => 600
            ),

            'square' => array(
                'crop' => true,
                'max_width' => 300,
                'max_height' => 300
            ),

            'thumbnail' => array(
                'max_width' => 100,
                'max_height' => 100
            )
        )
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-05 17:52:52

我只是碰到了同样的问题。在深入研究代码之后,我发现当它循环遍历图像版本时,它将结果图像对象保存在缓存中。所以在处理“小”之后..。结果图像对象( 150 X 150 )的缓存版本被称为文件。

因此,源文件被简单地复制到中、大型、xlarge和square,因为代码认为图像是150 x 150。然而,缩略图被处理,因为它小于150 x 150。

为了解决这个问题,您可以将no_cache选项添加到映像版本中--这会降低代码的效率,但也解决了您的(和我的)问题。

所以您的代码将如下所示:

代码语言:javascript
复制
'image_versions' => array(
    // The empty image version key defines options for the original image:
    '' => array(
        // Automatically rotate images based on EXIF meta data:
        'auto_orient' => true
    ),
    'small' => array(
        'max_width' => 150,
        'max_height' => 150,
        'no_cache' => true
    ),

    'medium' => array(
        'max_width' => 200,
        'max_height' => 200,
        'no_cache' => true
    ),

    'large' => array(
        'max_width' => 400,
        'max_height' => 400,
        'no_cache' => true
    ),

    'xlarge' => array(
        'max_width' => 600,
        'max_height' => 600,
        'no_cache' => true
    ),

    'square' => array(
        'crop' => true,
        'max_width' => 300,
        'max_height' => 300,
        'no_cache' => true
    ),

    'thumbnail' => array(
        'max_width' => 100,
        'max_height' => 100,
        'no_cache' => true
    )
)
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27968015

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档