Author Topic

Mark Overduin

Wednesday 27 August 2003 4:27:22 am

Comment13261

Well, that didn't do the trick either...

I had to use images right away, so I programmed something. It's really simple. All the function does, is change the width/height of the image.
At first, I wanted to create real thumbnails (a new image: a copy of the original image, only smaller)

This is my code:
- - - code - - -
"/design/mydesign/override/template/line_article.tpl" (or just 'article.tpl'):
{$node.data_map.thumbnail.content[original].full_path|img_original}
or
{$node.data_map.thumbnail.content[original].full_path|img_thumbnail}

"/kernel/common/eztemplateautoload.php":
include ("marksPHPfunctions.inc.php");
$eZTemplateOperatorArray[] = array('class_parameter' => array('img_thumbnail' => 'img_thumbnail', 'img_original' => 'img_original'),
'operator_names' => array ('img_thumbnail', 'img_original'));

"/kernel/common/marksPHPfunctions.inc.php":
function resizeImage ($path2img, $newWidth, $newHeight)
{
$tmp = getimagesize ($path2img);
$width = $tmp[0];
$height = $tmp[1];
unset ($tmp);

if ($width >= $height)
{
if ($width > $newWidth)
{
$tmp = $width / $newWidth;
$width = $width / $tmp;
$height = $height / $tmp;
unset ($tmp);
}
}
if ($height > $newHeight)
{
$tmp = $height / $newHeight;
$height = $height / $tmp;
$width = $width / $tmp;
unset ($tmp);
}
$result = "<img src=\"/$path2img\" width=\"$width\" height=\"$height\" border=\"1\" align=\"right\">";
return ($result);
}

function img_thumbnail ($path2img)
{
$result = resizeImage ($path2img, 100, 75);
return ($result);
}

function img_original ($path2img)
{
$result = resizeImage ($path2img, 200, 150);
return ($result);
}

function getFilename ($path2img)
{
$filename = explode ("/", $path2img);
$filenameSize = sizeof ($filename);
$filename = $filename[$filenameSize-1];
return ($filename);
}
- - - - - - - - -

Maybe someone can use this also...

I know this is a lousy solution, but I had to use images, so... Plz don't mind the bad coding, I made in what, 40 minutes?
I'll get rid of it, as soon as the ezP3-way works.

-- Mark