Elxis CMS Forum

Support => Elxis 2008 developers guide => Topic started by: datahell on September 28, 2007, 11:51:38

Title: Thumbnails generation
Post by: datahell on September 28, 2007, 11:51:38
Elxis 2008 has a build-in feature for thumbnails generation using GD2 PHP library.

Usage

Parameters:
$w = thumbnail width in pixels (ie 64)
$h = thumbnail height in pixels (ie 64)
$keepratio = 0 or 1 (keep picture aspect ratio or not)
$image = image's path relative to Elxis root dir (i.e. images/logo.png)

We create the thumbnail by calling this file: /includes/thumb.php
We also need to pass thumbnail parameters in the url via the GET method.
We store thumbnail parameters in a variable named fi witch is constructed like this:

$fi = base64_encode($w.','.$h.','.$keepratio.','.$image);

Our final link would be:
$thumb_url =$mosConfig_live_site.'/includes/thumb.php?fi='.$fi;

And here is the html thumbnail:

echo '<img src="'.$thumb_url.' " width="'.$w.'" height="'.$h.'" alt="thumbnail" />';

If thumbnail can not be generated a default one is being displayed (images/M_images/story.png).

Notice: only local images are being  processing.
Valid image extensions: 'gif', 'jpeg', 'jpg', 'png', 'wbmp', 'bmp'
Valid $fi characters: a-z, A-Z, 0-9 and the symbols:   . / - , _