search
HomeCMS TutorialDEDECMSWhat should I do if the thumbnail is distorted when calling DreamWeaver CMS?

Solution to the distortion of thumbnails called by DreamWeaver cms: 1. In "System-Attachment Settings", set the default width and height of the thumbnails to be greater than or equal to the maximum size of all called thumbnails in the entire site; 2. Open the "/include/extend.func.php" file and add the code as "function thumb($imgurl, $width, $height, $bg = true){...}".

What should I do if the thumbnail is distorted when calling DreamWeaver CMS?

The operating environment of this tutorial: Windows 10 system, DedeCMS version 5.7, Dell G3 computer.

What should I do if the thumbnail is distorted when calling DreamWeaver cms?

Solution to dede thumbnail distortion and blurring

Since dedecms only generates one size thumbnail by default, the thumbnails required in different pages of a website are often The thumbnails are inconsistent in size and proportion, which results in unclear and distorted thumbnails, which cannot meet the needs of most websites. This article gives an ultimate solution

Modification method:

1. To obtain clear thumbnails, you need to have a large enough image and crop it accurately. The following method is to crop based on the thumbnail (because some websites in the original image have watermarks), so you must Make sure that the original thumbnail is large enough, so you need to make some settings: System - Attachment Settings, set the default width and default height of the thumbnail to be greater than or equal to the maximum size of all the thumbnails called in your entire site. Please also cut it to be large enough for manual cutting. (No need to cut it by hand)

2. Open the /include/extend.func.php file (Note: This file is prepared for secondary development and used for functional method expansion)

Add the following code before the last ?>:

function thumb($imgurl, $width, $height, $bg = true)
{
global $cfg_mainsite,$cfg_multi_site;
$thumb = eregi("http://",$imgurl)?str_replace($cfg_mainsite,'',$imgurl):$imgurl;
list($thumbname,$extname) = explode('.',$thumb);
$newthumb = $thumbname.'_'.$width.'_'.$height.'.'.$extname;
if(!$thumbname || !$extname || !file_exists(DEDEROOT.$thumb)) return $imgurl;
if(!file_exists(DEDEROOT.$newthumb))
{
include_once DEDEINC.'/image.func.php';
if($bg==true)
{
ImageResizeNew(DEDEROOT.$thumb, $width, $height, DEDEROOT.$newthumb);
}
else
{
ImageResize(DEDEROOT.$thumb, $width, $height, DEDEROOT.$newthumb);
}
}
return $cfg_multi_site=='Y'?$cfg_mainsite.$newthumb:$newthumb;
}

Calling method:

[field:picname function='thumb(@me,$width,$height,$bg)'/]

Parameter description:

$width: thumbnail width (integer)

$height: Thumbnail height (integer)

$bg: Whether to fill with blanks, automatically filled by default, background fill color is in the system-accessory settings (true/false)

Example:

Call a thumbnail with a length and width of 100 pixels: [field:picname function='thumb(@me,100,100)'/]

Retain the original proportion , no automatic filling (not recommended): [field:picname function='thumb(@me,100,100,false)'/]

Recommended learning: dedecms tutorial

The above is the detailed content of What should I do if the thumbnail is distorted when calling DreamWeaver CMS?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor