Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

'On The Fly' Auto Thumbnailer using GD Library 2.1


mloeffen

Recommended Posts

Hi,

Omg what have you done there????

 

1. try putting the sts code before the code from tep_get_image() like:

////
// The HTML image wrapper function
 // "On the Fly" Auto Thumbnailer using GD Library, servercaching and browsercaching
// Scales product images dynamically, resulting in smaller file sizes, and keeps
// proper image ratio. Used in conjunction with product_thumb.php t/n generator.
function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

// START STS v4.4:
  global $sts; 
	  $sts->image($src); // Take image from template folder if exists.
// END STS v

 

2. delete (the sts code needs to be replaced as i said in point 1 but for a better understanding I showed all the wrong code within your tep_get_image() function):

				 {

// START STS v4.4:
  global $sts; 
	  $sts->image($src); // Take image from template folder if exists.
// END STS v4.4

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
$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 = intval($image_size[0] * $ratio); // Patch osc-060817
	} elseif (tep_not_null($width) && empty($height)) {
	  $ratio = $width / $image_size[0];
	  $height = intval($image_size[1] * $ratio); // Patch osc-060817
	} 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;

 

Now it should work. I use also rc2a and sts 4.5.8 and I'm going to use SEO.

Link to comment
Share on other sites

  • Replies 556
  • Created
  • Last Reply

Top Posters In This Topic

I installed this today and while the thumbnails looked much better it does not appear to be cacheing any of them since I can view the items under a given category, switch to a different category (waiting for the picture generation) and then going back to the original category just to sit and wait for the thumbnails to be re-generated.

 

What directory would I check to see if thumbnail files are being generated? Any help? I'm relatively new to osCommerce and have been all over the documentation for OSC as well as this contribution but can't find out why the browsing is so slow.

 

Thanks in advance for any assistance,

HoustonFirefox

Link to comment
Share on other sites

I can't figure what's going on here. For some reason the thumbnailer won't display the images in this category on my site:

 

http://www.kwdhasit.com/watches-smith-wess...20_121_124.html

 

I've been using this contribution for a few months now with no problems at all.

 

 

I figured it out, some of my picture directories have ampersands in them.

Link to comment
Share on other sites

could and would you help me with a problem concerning the contribution otf thumbnailer?

i am trying to find out what it is for months now and i am getting nowhere.

 

the error that comes up is:

Warning: is_file() [function.is-file]: open_basedir restriction in effect. File(/includes/languages/dutch/images/icon.gif) is not within the allowed path(s): (/www/htdocs/hancy:/tmp) in /www/htdocs/hancy/admin/includes/functions/html_output.php on line 72

 

and the listing of html_output.php until line 75 is below.

i checked the code with the readme a hundred times and stil can't find where i went wrong.

 

thanks in advance

 

<?php

/*

$Id: html_output.php,v 1.29 2003/06/25 20:32:44 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

////

// The HTML href link wrapper function

function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL') {

if ($page == '') {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');

}

if ($connection == 'NONSSL') {

$link = HTTP_SERVER . DIR_WS_ADMIN;

} elseif ($connection == 'SSL') {

if (ENABLE_SSL == 'true') {

$link = HTTPS_SERVER . DIR_WS_ADMIN;

} else {

$link = HTTP_SERVER . DIR_WS_ADMIN;

}

} else {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');

}

if ($parameters == '') {

$link = $link . $page . '?' . SID;

} else {

$link = $link . $page . '?' . $parameters . '&' . SID;

}

 

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

return $link;

}

 

function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') {

if ($connection == 'NONSSL') {

$link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;

} elseif ($connection == 'SSL') {

if (ENABLE_SSL_CATALOG == 'true') {

$link = HTTPS_CATALOG_SERVER . DIR_WS_CATALOG;

} else {

$link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;

}

} else {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');

}

if ($parameters == '') {

$link .= $page;

} else {

$link .= $page . '?' . $parameters;

}

 

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

return $link;

}

 

////

// The HTML image wrapper function

// "On the Fly" Auto Thumbnailer using GD Library, servercaching and browsercaching

// Scales product images dynamically, resulting in smaller file sizes, and keeps

// proper image ratio. Used in conjunction with product_thumb.php t/n generator.

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

 

// if no file exists display the 'no image' file

if (!is_file($src)) {

$src = "images/no_image.jpg";

}

Link to comment
Share on other sites

the error that comes up is:

Warning: is_file() [function.is-file]: open_basedir restriction in effect. File(/includes/languages/dutch/images/icon.gif) is not within the allowed path(s): (/www/htdocs/hancy:/tmp) in /www/htdocs/hancy/admin/includes/functions/html_output.php on line 72

 

and the listing of html_output.php until line 75 is below.

i checked the code with the readme a hundred times and stil can't find where i went wrong.

 

thanks in advance

 

I think the problem is with the open_basedir in /etc/php.ini. Your html_output.php is the same as mine (which works).

 

Do you have access to your php.ini? Mine is not set:

;open_basedir =

 

Some googling on open_basedir will get you on the right track I think :)

 

good luck!

gina

Link to comment
Share on other sites

Hi,

I am a newbie and am giving this a go to install.

 

Question..... Below it says to check that it says catalog. The path to my oscommerce is www.mywebsite.com/store and not www.mywebsite.com/catalog

 

Below it is: 'DIR_WS_HTTP_CATALOG', '/catalog/'

My file it is: 'DIR_WS_HTTP_CATALOG', '/store/'

 

Can I still install this under my store? If not, does that mean I would have to change all the 'catalog' to 'store'?

Thanks

 

 Step #4 - Verify config settings
In catalog/includes/configure.php

Verify the following code exists (21, 22, 23)


 define('DIR_WS_HTTP_CATALOG', '/catalog/');
 define('DIR_WS_HTTPS_CATALOG', '/catalog/');
 define('DIR_WS_IMAGES', 'images/');
		Note: Check this configuration file to make sure the path is set correctly for both your catalog directory and your images directory.

With the above example, the DIR_WS_HTTP_CATALOG value should be /catalog/ and the DIR_WS_IMAGES value images/. (Notice that it doesn't have a leading slash)

Link to comment
Share on other sites

i have installed the auto thumbnailer and for the most it works great, love the idea behindit but i have one little problem, the images shown for the products on their individual pages have the images all squashed...and ive tried changing the image h + w parameters in the admin and in the script (the script is unmodified atm) but still all the images are 47px high and approx 170 - 200 width and squashed.

 

Any solutions?

 

spdev

Link to comment
Share on other sites

Hi Grinse !

 

Thanks for your upgrade: v.2.4

I have using this contrib almost 2 years and never had a problem.

Now I decided to upgrade it to v.2.4, because of problems with server CPU load on my hosting.

 

So what I did. I just replaced these 2 files:

from yours rc2a files\catalog\includes\functions: html_output.php

from yours new files\catalog: product_thumb.php

 

The result is:

 

Fatal error: Call to a member function on a non-object in /home/mysite/www/www/catalog/includes/functions/html_output.php on line 84

 

Ok, then I have returned the old html_output.php and the site work, but the generated thumbs are black and white few pixels points only :'(

 

What is the problem with v.2.4? Can you help?

Link to comment
Share on other sites

Thank you for your info!

I missed cleaning the replaced files from other contributions (or included the wrong files).

 

But if you had checked these file (html_output) on line 84 you would have seen that (its code for simple template system and some line above (and underneath) sts modification is mentioned. ;)

 

But I fixed that and now just use the fixed (newer version).

 

Btw. the new abilitys are not in includes/functions/html_output (ok in the admin/includes/functions/html_output is one), they are in admin/categories.php.

Link to comment
Share on other sites

Thank you for your help !

Now the problem with html_output.php is fixed!

 

I also replaced and new files/catalog/product_thumb.php

But this file now produce thumbs like this one:

 

product_thumb.jpg

 

the older product_thumb.php(2 years old) produce correct image:

 

product_thumb-ok.jpg

 

please help me once again

Link to comment
Share on other sites

I really hope that someone can help me out with the installation of 'On The Fly'. My website is currently running on CRE Loaded B2B vs13.1 and I don't know if this contribution works with it. I have tried to install it myself but it doesn't seem to work. The instructions quite confusing to me. PLEASE HELP.

Link to comment
Share on other sites

I've installed this on one of my installations with no issues. However, I'm installing it on a client's installation and can't figure out why some of the thumbnails are showing up and some are broken. Any ideas as to why that might be?

Link to comment
Share on other sites

I had using the very old version, when they can not work on the transparence image (the transparence gone black)! Now, with 2.4, that problem gone. But, there is a big issuse for me. That is, with the old ver, it made thumb image 1 time only and save in folder images/imagecache. When I browser page, with which image has thumb image, the page with read that thumb image. The src of image like this : images/imagecache/xyaadasda_64x83.jpg

But now, althrought the thumb image had been created, when browser page (back, next, refresh ), it alway re makes the image thumb and overwrite in image/ . So, the page with be load very slow (very very slower than the old GD Thumb). And the src of thumb image in this case : /catalog/product_thumb.php?img=images/7in1L.jpg&w=60&h=80 . Server with work so much if alway do like that !

 

How to fix it ? And where in admin panel to config it ?

Paint for VietNamese :

Link to comment
Share on other sites

I've installed this on one of my installations with no issues. However, I'm installing it on a client's installation and can't figure out why some of the thumbnails are showing up and some are broken. Any ideas as to why that might be?

Anyone have any ideas on what might be causing some thumbs to show but not others? Could it be due to an older version running? How can I check for sure what version the client is running?

Link to comment
Share on other sites

  • 3 weeks later...

Hi, I'm testing out a new install of v2.2 on XP Pro running IIS with PHP5.2.5 and MySQL 5. The only contribution is "On The Fly'.

 

Thumbnails are displaying perfectly with Firefox but I'm having trouble with IE. IE is only showing some of the thumbnails and if I refresh the screen then some of the missing thumbnails appear and some of the previously displayed thumbnails disappear.

 

I've increased max_execution_time in PHP.ini but that didn't change anything.

 

Any ideas anyone?

 

Mick

Link to comment
Share on other sites

Thumbnails are displaying perfectly with Firefox but I'm having trouble with IE. IE is only showing some of the thumbnails and if I refresh the screen then some of the missing thumbnails appear and some of the previously displayed thumbnails disappear.

 

any ideas anyone? works great in Firefox and randomly in IE. It must be something simple since Firefox is ok.

 

Mick

Link to comment
Share on other sites

any ideas anyone? works great in Firefox and randomly in IE. It must be something simple since Firefox is ok.

 

Mick

 

 

I had the same problem. It was caused by Ultimate SEOs. The fix was to Reset SEO URLs Cache.

Link to comment
Share on other sites

I had the same problem. It was caused by Ultimate SEOs. The fix was to Reset SEO URLs Cache.

 

Thanks for the suggestion Kalyn. I've reset both the IE cache and thumbnail cache and still the same result :(

 

Not the end of the world - if I can't find a solution to this soon then I'll try out some of the other thumbnail contributions and hopefully one of them will work with my configuration.

Link to comment
Share on other sites

  • 2 weeks later...
Thanks for the suggestion Kalyn. I've reset both the IE cache and thumbnail cache and still the same result :(

 

Not the end of the world - if I can't find a solution to this soon then I'll try out some of the other thumbnail contributions and hopefully one of them will work with my configuration.

 

Try copying the image source in the address bar and seeing what happens, (http://www.server.com/catalog/product_thumb.php?img=images/sub/pretty_pic.jpg&w=95&h=100 for example).

 

If the image doesn't show up, you can use firefox with the firebug extension to view the errors that the script is generating.

 

In my case, I upgraded the contribution, and it was trying to recreate the thumbnails that already were created with an earlier version. I deleted the thumbnails and it works fine now.

 

-Mike

Link to comment
Share on other sites

I installed the images outside the default directory contrib so basically my images are stored in images/photos/ since I have a ton of product photos. When I install the script it works perfectly fine, except its reading on the /images/ folder and not the /images/photos/ folder. How can I change the script to read from /images/photos/ instead of /images/

Edited by dainbramaged05
Link to comment
Share on other sites

Hello to everybody!

I am trying to make run a "on the fly" im my osc commerce, but its quite imposible for me right now, i try to install the "otf autothumb v2.4fix3" i replace the files, and upload de mysql file, but when i am trying to enter to the admin./.catalog in this file

 

http://www.soloazar.com.ar/catalog/admin/categories.php?selected_box=catalog

 

apears this error

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/soloazar.com.ar/htdocs/catalog/admin/includes/functions/database.php on line 99

 

in the line 99 i have this

 

function tep_db_fetch_array($db_query) {

return mysql_fetch_array($db_query, MYSQL_ASSOC);

}

 

And im really confused, because i dont know how to solve it.

 

The only contribution instaled in the osc, before thisone is the sts template system.

 

Any Help will be eternaly regarded.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...