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

softyun3年前cms教程43


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

标签: dedecms
免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

织梦CMS(DedeCMS) 开始收费了,一个网站授权费5800元!

织梦cms(dedecms) 开始收费了,一个网站授权费5800元!近日,织梦CMS (DedeCMS) 发布了关于商业使用授权的通告。通告称:根据 DedeCMS 授权协议,除个人非营利网站外,均需...

织梦dedecms文章被评论后发短消息给作者的方法

织梦dedecms文章被评论后发短消息给作者的方法DedeCMS文章被别人评论后系统短消息通知作者的代码成功,现在特别将方法分享给大家,需要修改的文件是:/plus/feedback.php,小编教你...

织梦上传本地视频后 文件管理器中不显示解决办法

织梦上传本地视频后 文件管理器中不显示解决办法以上传mp4文件为例首先修改后台设置后才可以上传mp4文件系统基本参数 - 附件设置 - 允许的多媒体文件类型,添加mp4 然后修改代码使文件管理器显示m...

织梦cms转移迁移wordpress、讯睿CMS、pbootcms、云优CMS、易优CMS(eyoucms)等

织梦cms如何转移迁移到其它免费开源cms或授权价格低的CMS系统呢?其实,织梦cms转移迁移并不是十分容易,因为不仅要做数据库的迁移工作,还要保证数据结构相同。同时dedecms原有url尽量保持不...

DEDECMS织梦内容页调用seotitle标题的写法

DEDECMS织梦内容页调用seotitle标题的写法首先方法一,直接用织梦的sql实现:<span style="font-size:14px;">1  <title>  {...

PHP脚本快速将dedecms一键转换至wordpress程序

dedecms程序目前需要商业授权才可以使用,虽然以前也有类似的版权声明,但是这次应该是认真的。而且发出最后的通告,如果我们不购买商业授权(需要5800元一个站点),那可能遭受类似某拓CMS一样的法律...