Implement code to achieve more beautiful and neat thumbnails in Dedecms _dedecms

Source: Internet
Author: User
Just beginning to use Dede soon, the initial collection found that automatically generated thumbnail image is based on the maximum length of the custom, the original proportion of the reduction of the original picture, is not conducive to the image index page layout, forced to use the CSS in the automatic Judgment adjustment width-but more resource consumption. So still decided to change the function of the thumbnail--again thanks to Dede Open source!!

Modify File: inc_photograph.php

Copy Code code as follows:

if ($toWH <= $srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($srcH/$srcW);
}
else{
$ftoH = $toH;
$ftoW = $ftoH * ($srcW/$srcH);
}

Change to

Copy Code code 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 Code code as follows:

($ni, $im, 0,0,0,0, $ftoW, $ftoH, $srcW, $srcH)


Change to

Copy Code code as follows:

($ni, $im, 0,0, $src _x, $src _y, $ftoW, $ftoH, $srcW, $srcH)


In fact, a small change, that is, in the original image to intercept the largest area of the custom thumbnail aspect ratio of the column to generate thumbnails.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.