【问题标题】:blueimp jquery file uploader image_versions doesn't workblueimp jquery 文件上传器 image_versions 不起作用
【发布时间】:2015-01-15 16:19:45
【问题描述】:

我已经上传了 blueimp jquery 文件。我试图制作更多的 image_versions。 第一个和最后一个 image_version 确实有效。在我的情况下,''、'small' 和 'thumbnail' 有效,另一个不工作。 在其他 image_versions 图像将被上传,但不会调整到正确的大小。

这是我的代码片段:

'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
            )
        )

【问题讨论】:

    标签: jquery image blueimp uploader


    【解决方案1】:

    我刚刚遇到了同样的问题。在深入研究代码后,我发现当它遍历图像版本时,它会将生成的图像对象保存在缓存中。因此,在处理“小”之后...生成的图像对象 (150 x 150) 的缓存版本被称为文件。

    因此,源文件被简单地复制为 medium、large、xlarge 和 square,因为代码认为图像是 150 x 150。但是缩略图会被处理,因为它小于 150 x 150。

    要解决此问题,您可以将 no_cache 选项添加到您的图像版本 - 这会降低代码效率,但可以解决您(和我)的问题。

    所以你的代码看起来像这样:

    '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
        )
    )
    

    【讨论】:

    • 'no_cache => true' 成功了。为这个问题浪费了一整天。终于找到了你的解决方案。谢谢 :) (y)
    猜你喜欢
    • 1970-01-01
    • 2014-12-24
    • 1970-01-01
    • 2013-05-15
    • 1970-01-01
    • 1970-01-01
    • 2017-08-30
    • 2013-04-29
    • 2015-09-29
    相关资源
    最近更新 更多