Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

[Contribution] oscThumb


Recommended Posts

Hi Guys.


We're using the contrib and it's working fine.


Just recently, we've started to do some A/B testing using Google's Website Optimizer and we've found that OSCThumbs stops working properly on the 'variant page'. The contrib is continuing to work fine on the original page.


The variant page is an exact copy of the original page, but with some Google script code just under the <head> tag. You can see this code below, but it's JS, and shouldn't have any effect on OscThumb.


On the variant page, Oscthumb is failing to show the images as animated pop-ups, it just opens the images in new pages.


Does Oscthumb have any settings that depend on the name of the page that the contrib appears on? Would changing this page make the settings not valid?


One last thing - in FF Firebug, we see the following error


$("div#fancy a").fancybox is not a function


Clearly this is the problem, but *why* is fancybox not a function - it works just fine in the original page?


Any help much appreciated....


Google Website Optimzer JS code below....


<!-- Google Website Optimizer Tracking Script -->
<script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['gwo._setAccount', 'UA-xxxxxxxx-2']);
 _gaq.push(['gwo._trackPageview', '/xxxxxxxxxx/test']);
 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
<!-- End of Google Website Optimizer Tracking Script -->

Link to comment
Share on other sites

  • Replies 443
  • Created
  • Last Reply

Top Posters In This Topic

Link to comment
Share on other sites

The kind people at the phpThumbs forums said I need to wrap htmlentities around the img src like this:

echo '<img src="'.htmlentities('/phpThumb/phpThumb.php?src=/images/pic.jpg&w=50', ENT_QUOTES).'">';
echo '<img src="'.htmlentities(phpThumbURL('src=/images/pic.jpg&w=50', '&', '/phpThumb/phpThumb.php'), ENT_QUOTES).'">';


How do I do that for the osCommerce image code here:

// The HTML image wrapper function
 function tep_image_original($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
   $image = '<img src="' . tep_output_string($src) . '" 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);
    } elseif (tep_not_null($width) && empty($height)) {
	  $ratio = $width / $image_size[0];
	  $height = intval($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;

Link to comment
Share on other sites

Is there a way to clear the cache from the admin or do I need to clear out the contents of phpThumb/cache manually?

Link to comment
Share on other sites

  • 1 month later...



I met the problem that i cannot adjust watermark text to big. This look like the maximum point up to 5. This is because the people cannot see the small text. I readed the code from phpthumb.filters.php.

The code shows in the following:

Line 1178 $size = min(5, max(1, $size));


Although i hide the above code, but the watermark text is same, too small. I checked another place from phpthumb.filters.php.

This look like the following code cause the watermark text image to be fixed.

Line 1181 $text_width = 0;

Line 1182 $text_height = 0;

Line 1183 foreach ($textlines as $dummy => $line) {

Line 1184 $text_width = max($text_width, ImageFontWidth($size) * strlen($line));

Line 1185 $text_height += ImageFontHeight($size);

Line 1186 }


I changed "$text_width = 0;" to "$text_width = 100;", and changed "$text_height = 0;" to "$text_height = 100;", the problem still same. The watermark text is too small to me. Anyone can solve this problem? I cannot clear what is wrong with the above code.




Link to comment
Share on other sites

  • 1 month later...




I've installed this modulo on osc 2.3.1 and I'm having this problem:


Warning: require(includes/classes/oscthumb.php) [function.require]: failed to open stream: No such file or directory in /home/ambiancebijoux/www/catalogo_homolog/admin/includes/application_top.php on line 184


Warning: require(includes/classes/oscthumb.php) [function.require]: failed to open stream: No such file or directory in /home/ambiancebijoux/www/catalogo_homolog/admin/includes/application_top.php on line 184


Fatal error: require() [function.require]: Failed opening required 'includes/classes/oscthumb.php' (include_path='.:/usr/local/lib/php') in /home/ambiancebijoux/www/catalogo_homolog/admin/includes/application_top.php on line 184



SOmeone can helpme please?



Link to comment
Share on other sites

  • 3 months later...

I had a problem with:

<?php echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], '90', '90'); ?>


That it was not reconizing the width and the height correctly. After debuging I found out that the $alt tag was missing in html_output.


This is what you have to change: (around line 83 and 84)


just add $alt right after $src


 $oscthumb->set_type ($src, $alt, $width, $height, $thumbnail_type); // Detect the type of image we are currently processing
 if ($oscthumb->set_size ($src, $alt, $width, $height)==false) return false; // Choose the displayed width and height of the image, and if display something

Link to comment
Share on other sites

I used OscThumb in my last 231 Test Osc and everything worked fine until.....it stopped to loads some images....dunno why.

It stopped to resize images too. Only my problem? Think is a google problem but im not sure.


Question is...

Is there another contribution for osc 2.31 that works like OscThumb?

OscThumb is really nice but maybe a lil outdated

Link to comment
Share on other sites

I have done a re-write, I'll release fairly soon, no-doubt before osC 2.4 is out, which it will also work with.



Remember, What you think I ment may not be what I thought I ment when I said it.




Auto Backup your Database, Easy way


Multi Images with Fancy Pop-ups, Easy way


Products in columns with multi buy etc etc


Disable any Category or Product, Easy way


Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...

Did anyone ever got OscThumb and Lightbox on STS to work.?? I'm really curious about it.

The OscThumb works perfect on any aspect accept for Lightbox popup images.


I hope someone has a solution.



Link to comment
Share on other sites

Did anyone ever got OscThumb and Lightbox on STS to work.?? I'm really curious about it.

The OscThumb works perfect on any aspect accept for Lightbox popup images.


I hope someone has a solution.




I think it has something to do with the includes\modules\sts_inc\product_info.php since there is the lightbox for sts configured but i dont know what en where to change.

Link to comment
Share on other sites

Hi Sam,


do you have any news regarding your re-write version?

I'm testing the latest in osc 2.3.1 and I can't seem to put it to work, I've seen no image so far. It's working on my osc 2.2 shop though... Not sure what's different...


if you need a beta tester let me know.

Link to comment
Share on other sites

  • 5 weeks later...

I found the solution to make oscommerce + sts4.3.3 + oscThumb + lightbox with watermark in popup work!!!!

I'm not a php-wizard so the solution might not be so nice but it works for me and i thought to share it.


I found this script on B&T's Tips and Scripts (thanks very very much) and changed it just a little bit:


// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory as this script
// where this script is named watermark.php
// call this script with an image tag
// <img src="watermark.php?path=imagepath"> where path is a relative path from the document root - such as subdirectory/image.jpg
$imagesource = $_SERVER['DOCUMENT_ROOT']."/".$_GET['path'];
if (!file_exists($imagesource)) die();
$filetype = strtolower(substr($imagesource,strlen($imagesource)-4,4));
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (empty($image)) die();
$watermark = @imagecreatefrompng('watermark.png');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark,  $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
header("Content-type: image/jpeg");


This will be your watermark.php and save it in the root of your webshop.

Then make a watermark.php with background transparency and text or graphic transparency 20-25. Save it as PNG8 (small file size) and upload it also in your root folder.


Then in includes/modules/sts_inc/product_info.php find this (or something like it):


$template_pinfo['product_popup']= '<a rel="lightbox" href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) .
'" title="'. $product_info['products_model'] . ' - '. $product_info['products_name'] .' | '. $manufacturer['manufacturers_name'] .'">'.
$template_pinfo['imagesmall'] . '</a>'."\n";


and change to:


$template_pinfo['product_popup']= '<a rel="lightbox" href="watermark.php?path=/images/' . $product_info['products_image'] .
'" title="'. $product_info['products_model'] . ' - '. $product_info['products_name'] .' | '. $manufacturer['manufacturers_name'] .'">'.
$template_pinfo['imagesmall'] . '</a>'."\n";


The bold printed text "$template_pinfo['product_popup']= '<a rel="lightbox" href="watermark.php?path=/images/' . $product_info['products_image'] ." is the key. And there it works.

look for an example on http://www.gigaparts.nl (live shop!!)

Good luck all!

Edited by neetjedem
Link to comment
Share on other sites

  • 1 month later...

I always thought that my smallest oscThumb Thumbnails could be a bit sharper.

I figured out how to do that now.


If you want to add a bit more sharpness to your thumbnails your can add

$PHPTHUMB_DEFAULTS['fltr'] = array('usm|95');

to your /phpThumb/phpThumb.config.php

where the amount can be 1-255 (80 is default if you don't add this line).



Link to comment
Share on other sites

  • 8 months later...

Dear OscThumb user,


We are using Oscommerce for our automotive blog.

The contribution works well but we have another extra images contribution installed ( http://addons.oscommerce.com/info/1289 )

When we activate the OscThumb everything is cached well but the extra images from this contributions are not visible anymore

Do we need to change something at the extra images contribution to made this OSCThumb work well for the extra images.


Many thanks for anyone who can tell us what to do.

The extra image code is here:

 osCommerce, Open Source E-Commerce Solutions
 Copyright (c) 2002 osCommerce
 Released under the GNU General Public License

 Based on Extra images 1.4 from Mikel Williams
 Thanks to Mikel Williams, StuBo, moosey_jude and Randelia
 Modifications: Xav [email protected]

$products_extra_images_query = tep_db_query("SELECT products_extra_image, products_extra_images_id FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " WHERE products_id='" . $product_info['products_id'] . "'");
if (tep_db_num_rows($products_extra_images_query) >= 1){
$rowcount_value=1;  //number of extra images per row
?><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="10%" border="0" cellpadding="0" cellspacing="2">
<table width="10" border="0" align="center" cellpadding="0" cellspacing="2">

//$products_extra_images_query = tep_db_query("SELECT products_extra_image, products_extra_images_id FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " WHERE products_id='" . $product_info['products_id'] . "'");
while ($extra_images = tep_db_fetch_array($products_extra_images_query)) {
 <td align ="center" width="10%">
 <?php echo tep_image(DIR_WS_IMAGES . $extra_images['products_extra_image'], addslashes($product_info['products_name']), DIR_WS_IMAGES . $extra_images['products_extra_image'] . "'\"" )  . '<br><BR>'; ?></td>
if ($rowcount == $rowcount_value){echo '</tr><tr>'; $rowcount=1;}
else {$rowcount=$rowcount+1;}

Link to comment
Share on other sites

  • 8 months later...

I wanted to extend the functionality of oscThumb to use hard-coded images or any images I wanted. I built a slideshow that grabbed random product images from my store and displayed them (using file size logic to remove things that were too small). Some images are too big though, and I wanted to reduce the size.


The code I came up with seems to allow you to use oscThumb to generate css background-images, or any other image that you just want the URL for, much like Sir K.O. mentioned a looong time ago.


Also got a little Problem....

I have hardcoded images in my descriptions. To thumbnail them too i tried to call them like this


I put this code into description with str_replace by replacing the original <img src=" with above code.

Unfortunetaly it doenst work because of the hash!


anyone has any solution on how to thumb this images without having an hash?

or any other way?


My solution:

$picture1 = tep_image('images/your_image_name_or_other_image_identifier','', '500px','');
$picture1 = substr($picture1, 10, -46);

Then when you want to call it:

/* This is CSS */
background-image:url('<?php echo $picture1 ?>')


It's not really that hard, but took me hours to figure out. You don't need to hash the image name or anything - it's all done automatically. All my code does is cut off the first 10 and last 46 characters of what tep_image with oscThumb generates. Of course, you can pass along any parameters you want.



Link to comment
Share on other sites

  • 5 months later...

Since installing oscThumb, it seems that images are very slow to load. Does anyone have any suggestions how I can make the images load faster? Could there be some type of setting I overlooked?




(Old post I know, but the slow image loads have been an issue for many here)


Try this:

In phpthumb.config.php set these three options to null

$PHPTHUMB_CONFIG['cache_maxage'] = null;            // never delete cached thumbnails based on last-access time

$PHPTHUMB_CONFIG['cache_maxsize'] = null;           // never delete cached thumbnails based on byte size of cache directory

$PHPTHUMB_CONFIG['cache_maxfiles'] = null;          // never delete cached thumbnails based on number of cached files


I beleive what it does is keeping oscthumb from checking all your cached images every time an image is loaded.


It made a huge difference for me.



EDIT: I'm not sure at what point the image cache is renewed, if it is only done using cache_maxage or if it somewhere is reneved based on the cached image creation date. If it's only done based on cache_maxage, then the above may not be such a good idea.



Edited by MikeMike
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.

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...