osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

Size thumbnail image space dynamically if not found

This is a discussion on Size thumbnail image space dynamically if not found within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; I've added some code to the function tep_image in html_output.php to return an src to image pixel_trans.gif if the specified ...


Go Back   osCommerce and osCMax shopping cart software forums > osCommerce 2.2 Forums > osCommerce 2.2 Modification Help

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 01-16-2004, 03:04 AM
Member
 
Join Date: Aug 2003
Location: Southampton UK
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
NickW
Default Size thumbnail image space dynamically if not found

I've added some code to the function tep_image in html_output.php to return an src to image pixel_trans.gif if the specified image does not exist. I've also set width = 1 and height =1.

The above seems to work except that when the product image is not found for, eg the specials infobox, the space for a pixel_trans.gif is still the normal thumbnail size. I'm wanting to resize to 1 pixel square if the image is not found so that the normal sized blank thumbnail is not shown but instead only the text (and the transparent pixel).

Quote:
// The HTML image wrapper function
function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}

// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default

// Amended by ncw 15-01-04 to return pixel_trans.gif if image file does not exist
if (!file_exists($src)) {
$image = '<img src="' . tep_output_string(DIR_WS_IMAGES . 'pixel_trans.gif') . '" border="0" alt="' . tep_output_string($alt) . '" width="1" height="1">';
return $image;
} else {

$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';

if (tep_not_null($alt)) {
$image .= ' title=" ' . tep_output_string($alt) . ' "';
}

if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
if ($image_size = @getimagesize($src)) {
if (empty($width) && tep_not_null($height)) {
$ratio = $height / $image_size[1];
$width = $image_size[0] * $ratio;
} elseif (tep_not_null($width) && empty($height)) {
$ratio = $width / $image_size[0];
$height = $image_size[1] * $ratio;
} elseif (empty($width) && empty($height)) {
$width = $image_size[0];
$height = $image_size[1];
}
} elseif (IMAGE_REQUIRED == 'false') {
return false;
}
}

if (tep_not_null($width) && tep_not_null($height)) {
$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
}

if (tep_not_null($parameters)) $image .= ' ' . $parameters;

$image .= '>';

return $image;
} //ncw
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
let's see what we have here image not found info@ osCommerce 2.2 Modification Help 1 07-05-2005 02:33 AM
image size Anonymous osCMax v1.7 Discussion 0 04-15-2004 07:15 PM
Auto size header image FlipC osCMax v1.7 Discussion 0 11-29-2003 03:20 PM
thumbnail to large image. mikeyboy osCMax v1.7 Discussion 5 11-27-2003 01:38 AM
calculate image size? sheikyerbouti osCommerce 2.2 Modification Help 1 11-17-2002 08:37 AM


All times are GMT -8. The time now is 04:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax