search
HomeCMS TutorialDEDECMSHow to get the height and width of thumbnails in DedeCms

How to get the height and width of thumbnails in DedeCms

How does DedeCms get the height and width of the thumbnail?

DreamWeaver DedeCms gets the height and width of the thumbnail

Recommended learning:DreamWeavercms

Code requirements for certain waterfall flows The image must have a height, and the default thumbnail of Dreamweaver is just the stored image path. If you want to output the height of the image, you must use other methods. At present, I only think of using the getimagesize function, which is also a relatively simple implementation. Solution,

But there seems to be a problem in the actual application process, and I can’t figure out the reason. The specific manifestation is

$GLOBALS['cfg_basehost'] with www It cannot be obtained normally, such as http://www.xxx.com. If it is http://xxx.com, it can be obtained normally, which is extremely strange.

Of course, this method consumes a lot of resources.

include\helpers\extend.helper.php Finally add

if ( ! function_exists('getheight')) 
{ 
 function getheight($litpic){ 
 $litpicc = $GLOBALS['cfg_basehost'].$litpic; 
 $arr  = getimagesize($litpicc); 
 $resault = $arr[1];   // 此为高度 
 //$resault = $arr[0];    //此为宽度 
 return $resault; 
 } 
}

Use [field:litpic function="getheight(@me)"/] directly in the template to output the image height

Example

<img  src="/static/imghwm/default1.png"  data-src="[field:litpic/]"  class="lazy"   height=" [field:litpic function="getheight(@me)"/]" alt="How to get the height and width of thumbnails in DedeCms" >

The second method (recommended):

Add the following code before inserting into the database in /dede/article_add.php:

    //获取缩略图宽度及高度   
    $litpicc = $GLOBALS[&#39;cfg_basehost&#39;].$litpic;
    $arr  = getimagesize($litpicc);

$arr[ 0] is the width, $arr[1] is the height

Just insert these two values ​​​​into the database (please add the corresponding fields before)

This will save a lot of money through database calls system resource.

The above is the detailed content of How to get the height and width of thumbnails in DedeCms. 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

Video Face Swap

Video Face Swap

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

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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