雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

dedecms

當(dāng)前位置:主頁 > CMS教程 > dedecms >

織夢圖集 上傳圖片小于設(shè)定尺寸 縮略圖生成失敗的解決辦法

來源:本站原創(chuàng)|時間:2021-08-05|欄目:dedecms|點(diǎn)擊:

織夢圖集中,上傳的圖片像素寬高小于系統(tǒng)設(shè)置定的這個尺寸: 
較小的這些圖片就會無法生成縮略圖,導(dǎo)致圖集在網(wǎng)頁上縮略圖顯示X叉號,這應(yīng)該是織夢DEDEcms的一個歷史遺漏bug,可用下面方法修復(fù)。
/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會員設(shè)置、互動設(shè)置的方法

欄    目:dedecms

下一篇:DEDECMS調(diào)用指定文章ID來調(diào)用特定文檔

本文標(biāo)題:織夢圖集 上傳圖片小于設(shè)定尺寸 縮略圖生成失敗的解決辦法

本文地址:http://www.jygsgssxh.com/a1/dedecms/15425.html

更多dedecms

您可能感興趣的文章

閱讀排行

本欄相關(guān)

隨機(jī)閱讀

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有