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

89

织梦图集中,上传的图片像素宽高小于系统设置定的这个尺寸: 
较小的这些图片就会无法生成缩略图,导致图集在网页上缩略图显示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号了。
The End

相关推荐

织梦dedecms生成报错Fatal error: Allowed memory size of in /include
织梦生成静态html页面时报错:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /wwwroot/include/helpers/string.helper.php on line 121 字面意思理解是内存不足,很多朋友可能认为是内存不足问题,实际上不...
2023-10-13 dedecms安装使用
329

织梦Dedecms限制栏目列表生成的页数
有时候我们的文档特别的多,另外也是为防止网站被采集,全站文章被索引,所以要控制下织梦dedecms列表页面数量。 这样的话我们要具体怎么操作呢? 1、首先建立一个全局变量: 在系统-站点设置中添加一个新的变量,变量名称:cfg_listmaxpage,变量说明:栏目...
2023-05-24 dedecms安装使用
126

dedecms织梦全局变量调用方法总结
dedecms织梦的全局变量可以在/include/common.inc.php文件中看到,此文件内定义了大量的全局变量,详细自己去看看。 如果我们要实用dedeCMS织梦全局变量该如何调用: 第一种单独调用: {wmd:global.变量名 /},注意闭合,否则会以文本形式输出。这种一般适用...
2023-03-01 dedecms安装使用
238

织梦DEDECMS 栏目文章文章命名规则修改
织梦DEDECMS 栏目文章文章命名规则修改, 每次添加栏目的时候 都要改文章命名规则,十分麻烦, 修改下面这个地方就可以一改永亦,织梦模板网为您解答 找到\include\common.inc.php 搜索 $cfg_df_namerule 把: $cfg_df_namerule = {typedir}/{Y}/{M}{D}/{aid...
2021-09-24 dedecms安装使用
165

解决dedecms织梦系统{wmd:arclist keyword='动态获取关键词'}只生效一次
当我们通过{wmd:arclist keyword=关键词}来调用文章列表时,你会发现只在其中一个栏目里生效,在其他栏目,仍然显示上一次的关键词。 原因是由于arclist的缓存导致的。 只需修改/include/taglib/arclist.lib.php文件,大概在384行: $taghash = md5(seriali...
2021-09-24 dedecms安装使用
212

织梦dedecms数据库内容替换安全确认码怎么去掉
我们在使用织梦dedecms数据库内容替换时候,经常遇到 安全码 显示的无法识别或者不清晰,这个安全码的位置是在核心 - 批量维护 - 数据库内容替换,如果识别不了,这个页面还没有改变验证码的地方,只能重新刷新页面,如果我们不想要这个安全码的话,要怎么操...
2021-09-24 dedecms安装使用
109