[织梦教程] 织梦图集 上传图片小于设定尺寸 缩略图生成失败的解决办法

[复制链接]
查看959 | 回复12 | 2019-3-26 04:12:58 | 显示全部楼层 |阅读模式
织梦图集中,上传的图片像素宽高小于系统设置定的这个尺寸: 
较小的这些图片就会无法生成缩略图,导致图集在网页上缩略图显示X叉号,这应该是织梦DEDEcms的一个历史遗漏bug,可用下面方法修复。
/include/helpers/,这个文件中搜索,下面的代码:

if($srcW<=$toW && $srcH<=$toH ) return TRUE;
        $toWH=$toW/$toH;
        $srcWH=$srcW/$srcH;
        if($toWH<=$srcWH)
        {
            $ftoW=$toW;
            $ftoH=$ftoW*($srcH/$srcW);
        }
        else
        {
            $ftoH=$toH;
            $ftoW=$ftoH*($srcW/$srcH);
        }
 
然后用下面的大片代码替换:
 
$ftoW=$toH; 
[size=; font-size: inherit,inherit]                $ftoH=$toH; 
        ///
[size=; font-size: inherit,inherit]        if( $srcH<=$toH &&  $srcW<=$toW ) 
[size=; font-size: inherit,inherit]            { 
[size=; font-size: inherit,inherit]                $ftoW=$srcW; 
[size=; font-size: inherit,inherit]                $ftoH=$srcH; 
[size=; font-size: inherit,inherit]                if(function_exists("imagecreatetruecolor")) 
[size=; font-size: inherit,inherit]                { 
[size=; font-size: inherit,inherit]                    @$ni = imagecreatetruecolor($ftoW,$ftoH); 
[size=; font-size: inherit,inherit]                    if($ni) 
[size=; font-size: inherit,inherit]                    { 
[size=; font-size: inherit,inherit]                    imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); 
[size=; font-size: inherit,inherit]                    } 
[size=; font-size: inherit,inherit]                    else 
[size=; font-size: inherit,inherit]                    { 
[size=; font-size: inherit,inherit]                    $ni=imagecreate($ftoW,$ftoH); 
[size=; font-size: inherit,inherit]                    imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); 
[size=; font-size: inherit,inherit]                    } 
[size=; font-size: inherit,inherit]                    } 
[size=; font-size: inherit,inherit]                else 
[size=; font-size: inherit,inherit]                { 
[size=; font-size: inherit,inherit]                    $ni=imagecreate($ftoW,$ftoH); 
[size=; font-size: inherit,inherit]                    imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); 
[size=; font-size: inherit,inherit]                } 
[size=; font-size: inherit,inherit]                switch ($srcInfo[2]) 
[size=; font-size: inherit,inherit]                { 
[size=; font-size: inherit,inherit]                    case 1: 
[size=; font-size: inherit,inherit]                    imagegif($ni,$toFile); 
[size=; font-size: inherit,inherit]                    break; 
[size=; font-size: inherit,inherit]                    case 2: 
[size=; font-size: inherit,inherit]                    imagejpeg($ni,$toFile,100); 
[size=; font-size: inherit,inherit]                    break; 
[size=; font-size: inherit,inherit]                    case 3: 
[size=; font-size: inherit,inherit]                    imagepng($ni,$toFile); 
[size=; font-size: inherit,inherit]                    break; 
[size=; font-size: inherit,inherit]                    case 6: 
[size=; font-size: inherit,inherit]                    imagebmp($ni,$toFile); 
[size=; font-size: inherit,inherit]                    break; 
[size=; font-size: inherit,inherit]                    default: 
[size=; font-size: inherit,inherit]                    return false; 
[size=; font-size: inherit,inherit]                } 
[size=; font-size: inherit,inherit]                imagedestroy($ni); 
[size=; font-size: inherit,inherit]            } ///

        $toWH=$toW/$toH;
        $srcWH=$srcW/$srcH;
        if($toWH<=$srcWH)
        {
            $ftoW=$toW;
            $ftoH=$ftoW*($srcH/$srcW);
        }
        else
        {
            $ftoH=$toH;
            $ftoW=$ftoH*($srcW/$srcH);
        }
 
这样织梦上传的图,就不会显示x号了。
从0基础开始学习织梦dedecms建站,分享全套的织梦dedecms网站搭建教程、织梦安装使用教程。 汇聚了最全、最新的织梦cms建站教程。包含dedecms建站、仿站教程;dedecms系统使用常见问题;主题插件推荐下载等!欢迎学习!
回复

使用道具 举报

阿豆学长长ov | 2020-11-18 14:38:29 | 显示全部楼层
5kym.cn这个站资源太全了
回复

使用道具 举报

蜡烛2017 | 2021-1-4 23:40:54 | 显示全部楼层
我是来白嫖资源的!
回复

使用道具 举报

墙和鸡蛋 | 2021-1-12 06:34:22 | 显示全部楼层
厉害了悟空源码,这么多资源
回复

使用道具 举报

我是来白嫖悟空源码的资源的!
回复

使用道具 举报

Amy570 | 2021-6-26 13:00:58 | 显示全部楼层
5kym.cn这个站资源太全了
回复

使用道具 举报

因为我是真真 | 2021-10-24 18:42:21 | 显示全部楼层
加油!悟空源码,继续努力!支持你!
回复

使用道具 举报

喝意调伴除 | 2021-11-21 10:11:11 | 显示全部楼层
厉害了悟空源码,这么多资源
回复

使用道具 举报

苏警暗刚 | 2023-2-15 08:36:45 | 显示全部楼层
悟空源码太厉害,资源真多!
回复

使用道具 举报

慧眼识英雄1 | 2023-2-23 22:00:02 | 显示全部楼层
我是来白嫖资源的!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则