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

  织梦图集中,上传的图片像素宽高小于系统设置定的这个尺寸:

  较小的这些图片就会无法生成缩略图,导致图集在网页上缩略图显示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号了。

☉免责声明:本站所有模板均来自用户分享和网络收集,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服,我们核实后会立即删除。
☉本站提供的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
pbootcms模板网 » 织梦图集 上传图片小于设定尺寸 缩略图生成失败的解决办法

Pbootcms模板网 提供优质的模板集合

立即查看 了解详情