Thumbnail width and height in theme.php (the actual thumb on server) Thumbnail width and height in theme.php (the actual thumb on server)
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

Main Menu

Thumbnail width and height in theme.php (the actual thumb on server)

Started by allvip, November 06, 2019, 11:40:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

allvip

Hi.
No php function like imagesx etc works in theme.php
I need the width and height of each thumb_name.jpg.
Thanks.

allvip

The reason cpg_getimagesize did not work is because the thumbnail src is not the full path.
Anyway, cpg_getimagesize will give the width and height together as a string.

Solution

theme.php, theme_display_thumbnails

//get full thumnail path
$thumbImg = $thumb['image'];
preg_match('(<img[^>]* src=\"([^\"]*)\"[^>]*>)', $thumbImg, $matchesImg);
$thumbFilePath = $CONFIG['site_url'] . $matchesImg[1];   

// get width, height,attr and type
list($width, $height, $type, $attr) = getimagesize("$thumbFilePath");

then tokens to use in $template_thumbnail_view

The answer is not detailed.