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="[field:litpic/]" height=" [field:litpic function="getheight(@me)"/]">
The second method (recommended):
Add the following code before inserting into the database in /dede/article_add.php:
//获取缩略图宽度及高度 $litpicc = $GLOBALS['cfg_basehost'].$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!