czechmate1976
asked on
PHP: help with PHP Thumb class
I am using a php thumb class to display my images (class here http://wiki.github.com/masterexploder/PHPThumb/) following the instructions as strictly as possible but the images won't display at all. I have tried all sorts of things, still no luck. When checking the paths in the sourcecode, they look correct.. but still, can't make it work
The include file that is actually responsible for the images looks like this (below)
and the image tag then looks like this: (example version)
<img src="show_image.php?file=< ?php echo urlencode('/path/to/image. jpg'); ?>" />
(my version)
<img src="<?php echo INCLUDES_DIR ?>show_image.php?file=<?ph p echo urlencode(IMAGE_DIR.$image ->filename )?>" class="thumbnail" />
Please suggest what could be wrong, I thought I had tried everything but I am sure you will have loads of ideas. More heads know more :-)
The include file that is actually responsible for the images looks like this (below)
and the image tag then looks like this: (example version)
<img src="show_image.php?file=<
(my version)
<img src="<?php echo INCLUDES_DIR ?>show_image.php?file=<?ph
Please suggest what could be wrong, I thought I had tried everything but I am sure you will have loads of ideas. More heads know more :-)
<?php //Original
require_once 'path/to/ThumbLib.inc.php';
$fileName = (isset($_GET['file'])) ? urldecode($_GET['file']) : null;
if ($fileName h3. null || !file_exists($fileName))
{
// handle missing images however you want... perhaps show a default image?? Up to you...
}
try
{
$thumb = PhpThumbFactory::create($fileName);
}
catch (Exception $e)
{
// handle error here however you'd like
}
$thumb->adaptiveResize(80, 80);
$thumb->show();
?>
<?php //my customized version
require_once ('../library/ThumbLib.inc.php');
echo 'script running';
$fileName = (isset($_GET['file'])) ? urldecode($_GET['file']) : null;
if (!$fileName || !file_exists($fileName)) //h3. null
{
// handle missing images however you want... perhaps show a default image?? Up to you...
echo "MISSING IMAGE";
}
try
{
$thumb = PhpThumbFactory::create($fileName);
}
catch (Exception $e)
{
// handle error here however you'd like
echo 'ERROR OCCURED';
}
$thumb->adaptiveResize(150, 100);
$thumb->show();
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both of you guys for your help!!! YOu both helped a great deal. See you around :-)
ASKER
Oh, sorry, I totally did not notice that it was just you and no other expert:-) From all the coding, I lose my sight :-) Well, great job - points are yours
ASKER
That echo statement was to see something coming through, I did not realize there was no chance to view any of that. I have now tried using the example code from the class and extending it step by step to imitate my requirements, and found out that I cannot use absolute reference for teh '..?file=' to display the image, so now I am trying to just incorporate some of the try-catch error handling, but at least the images started showing up.
Just a quick question.. I guess you are familiar with the class to some extent, would you have any idea how to determine which dimension - width or height - is larger, so I can actually change the aim dimensions I need by finding out if an image is portrait or landscape format.
Thanks a lot again for your comment!!!