Shortly after I started using DEDE, I found that the automatically generated thumbnail pictures were actually reduced by the original image based on the customized maximum length and width and the original proportion, which was not conducive to the layout of the image index page. I had to use automatic judgment to adjust the height and width in CSS - but it was more resource-consuming. So I decided to change the thumbnail function - thanks again for the open source of DEDE! !
Modify file: inc_photograph.php
if($toWH<=$srcWH){
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
Change to
$ftoH=$toH;
$ftoW=$toW;
if ($toWH<=$srcWH) {
$src_Y = 0;
$src_X = ($srcW-$srcH*$toWH)/2;
$srcW = $srcH*$toWH;
} else {
$src_X = 0;
$src_Y = ($srcH-$srcW/$toWH)/2;
$srcH = $srcW/$toWH;
}
Key points:
($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH)
Change to
($ni,$im,0,0,$src_X,$src_Y,$ftoW,$ftoH,$srcW,$srcH)
In fact, just a small change is to capture a part of the column in the original image that meets the length and width ratio of the custom thumbnail in the length and width ratio.
Modify file: inc_photograph.php
Copy the codeThe code is as follows:
if($toWH<=$srcWH){
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
Change to
Copy the codeThe code is as follows:
$ftoH=$toH;
$ftoW=$toW;
if ($toWH<=$srcWH) {
$src_Y = 0;
$src_X = ($srcW-$srcH*$toWH)/2;
$srcW = $srcH*$toWH;
} else {
$src_X = 0;
$src_Y = ($srcH-$srcW/$toWH)/2;
$srcH = $srcW/$toWH;
}
Key points:
Copy the codeThe code is as follows:
($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH)
Change to
Copy the codeThe code is as follows:
($ni,$im,0,0,$src_X,$src_Y,$ftoW,$ftoH,$srcW,$srcH)
In fact, just a small change is to capture a part of the column in the original image that meets the length and width ratio of the custom thumbnail in the length and width ratio.