Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of obtaining the height and width of thumbnails by Dream Weaving DedeCms

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of weaving dream DedeCms to obtain the height and width of thumbnails, which is very detailed and has a certain reference value. Interested friends must read it!

How does Dream Weaving DedeCms get the height and width of thumbnails?

Dream weaving DedeCms gets the height and width of the thumbnail

Recommended study: dream weaving cms

Some waterfall stream code requires that the picture must have a height, but the default thumbnail of weaving dream is only the stored picture path. If you want to output the height of the picture, you have to use another way. At present, I only think of using the getimagesize function, which is also a relatively simple implementation.

But there seems to be a problem in the process of practical application, and I don't know what the reason is.

$GLOBALS ['cfg_basehost'] with www cannot be obtained normally. For example, http://www.xxx.com can be obtained normally if it is http://xxx.com. It is very strange that this kind of url can be obtained normally.

Of course, this approach consumes a lot of resources.

Include\ helpers\ extend.helper.php was last added

If (! Function_exists ('getheight') {function getheight ($litpic) {$litpicc = $GLOBALS [' cfg_basehost']. $litpic; $arr = getimagesize ($litpicc); $resault = $arr [1]; / / this is height / / $resault = $arr [0]; / / this is width return $resault;}}

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

Example

The second method (recommended):

Add the following code before / dede/article_add.php is inserted into the database:

/ / get thumbnail width and height $litpicc = $GLOBALS ['cfg_basehost']. $litpic; $arr = getimagesize ($litpicc)

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

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

In this way, the system resources are greatly saved through database calls.

These are all the contents of the method of Weaving Dream DedeCms to get the height and width of thumbnails. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report