What 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){...}".
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor
