Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Calculate Image Size not working


tflight

Recommended Posts

I've read dozens of discussions in this forum now regarding setting image sizes and dynamically calculating image sizes. I am trying to set osc so that product images are limited to being 225 pixels wide. The height should then be dynamically calculated based on the aspect ratio of the original image.

 

So my image settings are:

 

Small Image Width: 225

Small Image Height:

Calculate Image Size: true

 

However, with these settings the images are no longer displayed at all! Even in the source HTML the image tags are completely gone fro the products.

 

If I update my configuration with the following settings:

 

Small Image Width: 225

Small Image Height:

Calculate Image Size: false

 

Then the images do come back... but they are not scaled to a 225 pixel width. The original, unmodified image is displayed and the image tag in the HTML source has no width or height parameters given. I would have expected the images to retain the original height but be a 225 pixel width. This is not happening either.

 

What am I doing wrong?

Link to comment
Share on other sites

I've read dozens of discussions in this forum now regarding setting image sizes and dynamically calculating image sizes. I am trying to set osc so that product images are limited to being 225 pixels wide. The height should then be dynamically calculated based on the aspect ratio of the original image.

 

So my image settings are:

 

Small Image Width: 225

Small Image Height:

Calculate Image Size: true

 

However, with these settings the images are no longer displayed at all! Even in the source HTML the image tags are completely gone fro the products.

 

If I update my configuration with the following settings:

 

Small Image Width: 225

Small Image Height:

Calculate Image Size: false

 

Then the images do come back... but they are not scaled to a 225 pixel width. The original, unmodified image is displayed and the image tag in the HTML source has no width or height parameters given. I would have expected the images to retain the original height but be a 225 pixel width. This is not happening either.

 

What am I doing wrong?

 

 

Not sure why this is not working - you seem to have the right idea - I would however not rely on the *crude* resizing capability of osC - do your image work from the ground up - The payback is huge

 

For this read this tip http://www.oscommerce.com/forums/index.php?showtopic=140462

 

Charles

A kite flies highest AGAINST the wind !

 

"Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways, a lover in one hand, martini in the other, body thoroughly used up, totally worn out and screaming ~ WOO HOO!! What a ride!"

Link to comment
Share on other sites

Not sure why this is not working - you seem to have the right idea

 

Thanks for the reassurance that at least what I was doing was correct. I dug around until I found the offending code. In /catalog/includes/functions/html_output.php somewhere around line 88 is the following:

 

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

 

which I changed to be:

 

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

 

And presto, now everything works as it should.

Link to comment
Share on other sites

Thanks for the reassurance that at least what I was doing was correct. I dug around until I found the offending code. In /catalog/includes/functions/html_output.php somewhere around line 88 is the following:

 

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

 

which I changed to be:

 

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

 

And presto, now everything works as it should.

 

 

This seems to suggest your configure is not quite right - because you have had to re-inform html_output where to get your source image ! :D

 

If configure is set right the getimagesize should work - without all the info i think you have put a plaster on another problem.

 

The only way to tell is to see your configure,php's and relate them back to your cart directory structure

 

BTW - I like your style - when you solve a problem you tell us so other who are following the thread have an idea where to look B)

 

Charles

A kite flies highest AGAINST the wind !

 

"Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways, a lover in one hand, martini in the other, body thoroughly used up, totally worn out and screaming ~ WOO HOO!! What a ride!"

Link to comment
Share on other sites

This seems to suggest your configure is not quite right - because you have had to re-inform html_output where to get your source image !  :D

 

Hi Charles,

 

Thanks for the response. Here is a partial copy of my configure.php:

 

define('HTTP_SERVER', 'http://www.mycustomer.com'); // eg, http://localhost - should not be empty for productive servers
define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
define('ENABLE_SSL', false); // secure webserver for checkout procedure?
define('HTTP_COOKIE_DOMAIN', 'www.mycustomer.com');
define('HTTPS_COOKIE_DOMAIN', '');
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '');
define('DIR_WS_HTTP_CATALOG', '/');
define('DIR_WS_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '');
define('DIR_WS_IMAGES', '/images/');
define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
define('DIR_FS_CATALOG', '/Users/mycustomer/Sites/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

Link to comment
Share on other sites

Hi Charles,

 

Thanks for the response. Here is a partial copy of my configure.php:

 

define('HTTP_SERVER', 'http://www.mycustomer.com'); // eg, http://localhost - should not be empty for productive servers
define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
define('ENABLE_SSL', false); // secure webserver for checkout procedure?
define('HTTP_COOKIE_DOMAIN', 'www.mycustomer.com');
define('HTTPS_COOKIE_DOMAIN', '');
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '');
define('DIR_WS_HTTP_CATALOG', '/');
define('DIR_WS_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '');
define('DIR_WS_IMAGES', '/images/');
define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
define('DIR_FS_CATALOG', '/Users/mycustomer/Sites/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

 

Here is my amended configure for a shop installed one directory level down from root

 

If yours is in root just adjust as required - also I see your images path is set to '/images/' and not 'images/' as below note the first slash - maybe that was your problem.

 

// Define the webserver and path parameters

// * DIR_FS_* = Filesystem directories (local/physical)

// * DIR_WS_* = Webserver directories (virtual/URL)

define('HTTP_SERVER', 'http://www.mydomain.com'); // eg, http://localhost - should not be empty for productive servers

define('HTTPS_SERVER', 'https://mydomain.com'); // eg, https://localhost - should not be empty for productive servers

define('ENABLE_SSL', true); // secure webserver for checkout procedure?

define('HTTP_COOKIE_DOMAIN', 'www.mydomain.com');

define('HTTPS_COOKIE_DOMAIN', 'mydomain.com');

define('HTTP_COOKIE_PATH', '/catalog/');

define('HTTPS_COOKIE_PATH', '/catalog/');

define('DIR_WS_HTTP_CATALOG', '/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/catalog/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_CATALOG', '/home/****/public_html/catalog/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

Charles

A kite flies highest AGAINST the wind !

 

"Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways, a lover in one hand, martini in the other, body thoroughly used up, totally worn out and screaming ~ WOO HOO!! What a ride!"

Link to comment
Share on other sites

If yours is in root just adjust as required - also I see your images path is set to '/images/' and not 'images/' as below note the first slash - maybe that was your problem.

 

Hmmm... That doesn't work. If I change the image path to 'images/' then most of my images on the site are no longer displayed. (Note, it isn't that the HTML code is incorrect, the entire img tags are no longer there.)

 

Also, the other difference I saw was that I have

define('DIR_WS_CATALOG', '/');

in my configure.php file that you don't have. without that line then ALL images and CSS files become linked improperly and cannot be found on anything but the homepage. Weird.

 

In any case, my tiny change to the html_output file plus the adding in

define('DIR_WS_CATALOG', '/');

and using '/images/' seems to make everything work just fine. I have not seen any other problems as a result of my hacks.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...