Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

My product images scale poorly, please help!


sabotage79

Recommended Posts

I need my product image to be bigger than it is. Im talking about then the click on the product, and they are taken to the 'main' product page. The images don't scale very well, and so its hard to make out the text on the product. I have looked and some GD options (i think thats what its called, 2.01 on the fly scaling scripts), but my server doesnt support it, so I think my only option would be to use 'Big Images', or 'Mo Images', to make my product image look better.

 

Is there anyone out there who was in a simular situation and solved the problem of poor quality images? Also, my thumbnail images on the previous pages, the small ones.. they scale bad too.. so if I could fix that that would be great. Just remember I can't use any of the GD contribs that are available since my server doesn't support that. (they say because its beta, geesh) If someone could point me in the right direction, that would be wonderful!

 

Thanks!

Link to comment
Share on other sites

This is something I use in the Free Call for Price add-on for handling scaling and such.

 

My thanks to the person who wrote the original code before my changes to it, and sorry I cannot recall who you are :shock:

// BOF: WebMakers.com Added: FREE-CALL FOR PRICE-COMING SOON ETC.

function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

 if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED=='false') ) {

   return;

 }

// WebMakers.com Added: FREE-CALL FOR PRICE-COMING SOON ETC.

if ( $alt ) {

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

} else {

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

}

 if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) {

   $dont_calculate = 1;

 }

 if ( (CONFIG_CALCULATE_IMAGE_SIZE) && ((!$width) || (!$height)) ) {

   if ($image_size = @getimagesize($src)) {

     if ( (!$width) && ($height) ) {

       $ratio = $height / $image_size[1];

       $width = $image_size[0] * $ratio;

     } elseif ( ($width) && (!$height) ) {

       $ratio = $width / $image_size[0];

       $height = $image_size[1] * $ratio;

     } elseif ( (!$width) && (!$height) ) {

       $width = $image_size[0];

       $height = $image_size[1];

     }

   } elseif (IMAGE_REQUIRED=='false') {

     return '';

   }

 }

 if ( CONFIG_CALCULATE_IMAGE_SIZE && (!$dont_calculate) ){

   if ($image_size = @getimagesize($src)) {

     $ratio = $image_size[1] / $image_size[0]; // real ratio

     // do we need scaling

     if (($image_size[0] > $width) || ($image_size[1] > $height)) {

       $rx = $image_size[0] / $width;

       $ry = $image_size[1] / $height;

       if ($rx < $ry) {

         $width = $height / $ratio;

       } else {

         $height = $width * $ratio;

       }

     } else {

       $rx = $image_size[0] / $width;

       $ry = $image_size[1] / $height;

       if ($rx < $ry) {

         $width = $height / $ratio;

       } else {

         $height = $width * $ratio;

       }

     }

   }

 }

 if ( ($width) && ($height) ) {

   $image .= ' width="' . $width . '" height="' . $height . '"';

 }

 if ($params != '') {

   $image .= ' ' . $params;

 }

 $image .= '>';

 return $image;

}

// EOF: WebMakers.com Added: FREE-CALL FOR PRICE-COMING SOON ETC.

Link to comment
Share on other sites

Man I really wanted this to work. :shock:

I pasted the code at the end of catalog/includes/functions/html_output.php and go this error:

 

Fatal error: Cannot redeclare tep_image() (previously declared in C:htmlcatalogincludesfunctionshtml_output.php:66) in C:htmlcatalogincludesfunctionshtml_output.php on line 283

 

I tried removing line 283:

function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED=='false') ) {

return;

}

But I got a new error:

Parse error: parse error, unexpected '}' in C:htmlcatalogincludesfunctionshtml_output.php on line 340

 

So I don't know what to do from here. Im running release 09-26

 

Thanks!!

Ryan

Link to comment
Share on other sites

That needs to replace the existing code.

 

There is already a function tep_image ... rename that function tep_image_old and then paste in the new code and upload and test it :shock:

Link to comment
Share on other sites

Just my luck :?:

 

Fatal error: Call to undefined function: tep_href_link() in C:htmlcatalogincludesapplication_top.php on line 424

 

I pasted in the code, overwriting everything like u said in the instructions. I was suposed to delete everything and past that code in the file right? between the <?php ?> tags?

 

Something wrong :(

Link to comment
Share on other sites

You were suppose to rename the function tep_image to function tep_image_old

 

Then, beneath that function, make sure you are at the bottom of it, paste in the new function tep_image from the code above.

 

Don't delete everything in html_output.php as there are many functions in that file that are needed for other things.

 

You are basically just replacing one of them. But instead of deleting the old function out, you rename it so that you have it for later if you need it back for some reason.

Link to comment
Share on other sites

  • 1 year later...

I have the latest version and used the code above and see no difference in the quality of my thumbnail images. Any ideas here?

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 1 year later...

Hi,

I just want to be able to change my actual product image dimensions - how can I do that?

 

 

 

Never mind. Next time I do a search for a solution, I will just search for 'Vger'

Link to comment
Share on other sites

  • 2 months later...

if the posted code doesnt work you probably have a restriction on open_basedir in effect.

 

i added this:

if ($src{0} == "/" ) {
$src = realpath($_SERVER['DOCUMENT_ROOT']) . $src;
} else {
$src = realpath($_SERVER['DOCUMENT_ROOT']) . "/" . $src;
}

 

New function:

//// NIEUWE TEP_IMAGE
function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {
if ( (($src == '') || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED=='false') ) {
return;
}

if ( $alt ) {
$image = '<img src="' . $src . '" border="0" alt=" ' . htmlspecialchars($alt) . ' "';
} else {
$image = '<img src="' . $src . '" border="0" alt="' . htmlspecialchars($alt) . '"';
}
if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) {
$dont_calculate = 1;
}
if ($src{0} == "/" ) {
	$src = realpath($_SERVER['DOCUMENT_ROOT']) . $src;
	} else {
	$src = realpath($_SERVER['DOCUMENT_ROOT']) . "/" . $src;
}
if ( (CONFIG_CALCULATE_IMAGE_SIZE) && ((!$width) || (!$height)) ) {
	if ($image_size = @getimagesize($src)) {
		 if ( (!$width) && ($height) ) {
		   $ratio = $height / $image_size[1];
		   $width = $image_size[0] * $ratio;
		 } elseif ( ($width) && (!$height) ) {
		   $ratio = $width / $image_size[0];
		   $height = $image_size[1] * $ratio;
		 } elseif ( (!$width) && (!$height) ) {
		   $width = $image_size[0];
		   $height = $image_size[1];
		 }
	} elseif (IMAGE_REQUIRED=='false') {
	 return '';
	}
}
if ( CONFIG_CALCULATE_IMAGE_SIZE && (!$dont_calculate) ){
	if ($image_size = @getimagesize($src)) {
	 $ratio = $image_size[1] / $image_size[0]; // real ratio
	 // do we need scaling
		 if (($image_size[0] > $width) || ($image_size[1] > $height)) {
			   $rx = $image_size[0] / $width;
			   $ry = $image_size[1] / $height;
			   if ($rx < $ry) {
				 $width = $height / $ratio;
			   } else {
				 $height = $width * $ratio;
			   }
		 } else {
			   $rx = $image_size[0] / $width;
			   $ry = $image_size[1] / $height;
			   if ($rx < $ry) {
				 $width = $height / $ratio;
			   } else {
				 $height = $width * $ratio;
			   }
		 }
	}
}
if (($width) && ($height)) {
$image .= ' width="' . $width . '" height="' . $height . '"';
}
if ($params != '') {
$image .= ' ' . $params;
}
$image .= '>';
return $image;
}

Link to comment
Share on other sites

Forget the "realpath" that was a remainder of a test thingie.

 

For people who have an user account starting with ~ (like www.server.com/~myshop) replace the above code-snippet by this:

 

if (strstr($_SERVER['PHP_SELF'], '~')) {
	$path = substr($_SERVER["PATH_TRANSLATED"], 0, strpos($_SERVER["PATH_TRANSLATED"], '/', 14));
	if ($src{0} == "/" ) {
		$src = $path . $src;
		} else {
		$src = path . "/" . $src;
	}
} else {
	if ($src{0} == "/" ) {
		$src = $_SERVER['DOCUMENT_ROOT'] . $src;
		} else {
		$src = $_SERVER['DOCUMENT_ROOT'] . "/" . $src;
	}
}

 

or something...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...