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

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.

 

 

I am getting the same error. Anyone know of a fix?

Link to comment
Share on other sites

  • Replies 556
  • Created
  • Last Reply

Top Posters In This Topic

I am getting the same error. Anyone know of a fix?

 

I figured it out. I manually added the changes to admin/categories.php and the error went away. I believe that the file provided has some additional addon that was included in that file causing the error. Make the changes by comparing the files and only adding what you see inside the comments and you will get it to work.

Link to comment
Share on other sites

  • 2 weeks later...

I have a problem. All my thumbs directories with images are permission denided for me. So, I can't delete them or files in it via ftp. No changes for mkdir were in product_thumbs.php. Thumbs directories created should be 777, but they are 755.

Does any body have this problem? ((

Link to comment
Share on other sites

  • 3 weeks later...

Another great contribution! Thanks :).

Everything is working perfectly, allthough i would love to have one thing rescripted.

At this point, when entering a new product or changing an existing products details, there are 2 fields for uploading pictures ( i dont really understand why there are 2?) I want to rescript the auto thumbnailing (which uses the same picture as in enlarge popup), and use the 2 fields in the new product details screen (admin) for:

Field 1: To upload a picture that will be used in the enlargened popup.

Field 2: To upload a picture that will be used in the thumbnail box.

The reason i want to do this is to use watermarks in my enlargened pictures. I dont want these to show in the thumbnails. Does anyone know how i can fix this?

 

Help would be more than appreciated

Link to comment
Share on other sites

  • 4 weeks later...

Thanks for a great contribution! We're trying to install it now and have a quick question about a potentially missing file:

 

The readme file says, "Make a backup of the files that are going to be changed:

<snip>

* catalog/admin/includes/categories.php

<snip>"

 

But we do not have an admin/includes/categories.php file.

Should we?

 

We do have Categories in the store.

We do have an admin/categories.php file.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

This is a wonderful contribution but after installing it I am having a tiny problem with our current design. For some reason, a small spacer image is not showing up after the installation. If you go to gsmfanatics.com, you will see it in the header, along the tabs, on each corner the spacer image is missing.. If someone could help me out I would sincerely appreciate that.

 

Thank you!!

Link to comment
Share on other sites

Hi All,

 

Would like to know that, how do i prevent Auto Thumbnailer from resizing the spacer.gif at the size of 1px x 1px ... because it messy the theme design that used spacer image.

 

i have tried following,

 

// Don't calculate if the image is set to a "%" width

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

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

and even

 

// Dont calculate if a pixel image is being passed (hope you dont have pixels for sale)

if (!strstr($image, 'pixel') || (!strstr($image, 'spacer')) {

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

Hi, anyone know how to solve this ?

 

Thanks

 

 

 

Hi,

 

Anyone figured this out yet ? When I load the new html_outpout.php file my spacer.gif go 1px x 1px and also my backrgound gif is affected and my layout is completely messed ..

 

Hope to solve this asap :)

 

Thanks !

Link to comment
Share on other sites

Hi All,

 

Would like to know that, how do i prevent Auto Thumbnailer from resizing the spacer.gif at the size of 1px x 1px ... because it messy the theme design that used spacer image.

 

i have tried following,

 

// Don't calculate if the image is set to a "%" width

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

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

and even

 

// Dont calculate if a pixel image is being passed (hope you dont have pixels for sale)

if (!strstr($image, 'pixel') || (!strstr($image, 'spacer')) {

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

 

 

 

 

Hi,

 

Anyone figured this out yet ? When I load the new html_outpout.php file my spacer.gif go 1px x 1px and also my backrgound gif is affected and my layout is completely messed ..

 

Hope to solve this asap :)

 

Thanks !

 

 

Hi again :))

 

It seems I have found a solution to this ..... The following autothumbnailer doesnt have these issues with spacer.gif ....

 

http://www.oscommerce.com/community/contributions,2872/

 

It works for me :))

 

Try it !

Link to comment
Share on other sites

  • 3 weeks later...

Hello Amigos,

Everything with this contribution was working fine, but something must have changed.. When I click the image, nothing pops up. My server is not logging any errors. I've tried it on two computers so far.

 

The site is http://www.rootworkherbs.com

 

I'd really appreciate it if anyone could point me in the right direction to get this fixed.

 

Thanks!

 

Scott

Link to comment
Share on other sites

  • 1 month later...

Hi. I got a problem with image resizing. Installation was without any problem. Contribution works fine. But when i upload an image with smaller size (than height and width in admin panel), i got original image with thick black borders. Hot to fix this? Maybe white borders? Is this bug of gd library?

Link to comment
Share on other sites

  • 4 weeks later...

Hi!

 

Great contribution! :) I just installed it and it seems to be working very well.

 

One problem: because I replaced the tep_image function, I lost some previous modifications I made in that function that allowed swf to be handled as an embedded image. Some of my products are small flash movies/games, and it was nice having them display on product info pages and in the specials, etc. (even though they were downsized in the stock OsCommerce method of "squish it down").

 

Is there a way to add back in some kind of code that says "if a file is swf, bypass thumbnail function and pass it through as an embed"?

 

I really hope someone can help me with this. I've been fooling around with it, but each time I think i have it, I am rudely awakened!

 

Thanks so much!

Link to comment
Share on other sites

what have u tried.

 

I'd have thought a simple test such as

 

if (strstr($src, '.swf')) return tep_image_original ($src, $alt, $width, $height, $params);

 

would do. ;)

Sam

 

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

 

Contributions:

 

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

what have u tried.

 

I'd have thought a simple test such as

 

////
// The HTML image wrapper function

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $swf = 'no') {
  if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
    return false;
  }
$extension = substr($src, -4);
if ($extension == '.swf') $swf = 'yes';

// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
if ($swf == 'no') {
   $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
} else {
   $image = '<embed src="' . tep_output_string($src) . '"';
}

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

  if (((CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height))) && ($swf=='no')) {
    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)) && ($swf =='no')) $image .= ' ' . $parameters;

  $image .= '>';

  return $image;
}

////

 

The OTF contribution replaced all that - and there is no reference at all to swf - although I thought I saw it mentioned in some of the earlier versions.

 

Basically, I've been trying to integrate the bits of the old code that referenced swf into the new OTF code. I've also tried a few of the contributions that activate flash, but they are mainly for hard-coded embeds of swf on pages. They haven't had any effect on the product images.

 

BTW, the flash files ARE being thumbed - i can see the "thumb" string in the URL - but they just aren't rendering - all I get is an empty box. :(

 

Thanks for any ideas...

Link to comment
Share on other sites

sorry, I though u knew what u were doing!!

 

put back your original function, renaming it to tep_image_original

 

then put

 

if (substr($src, -4) == '.swf') return tep_image_original ($src, $alt, $width, $height, $params);

 

at the start of the new function

Sam

 

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

 

Contributions:

 

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

put back your original function, renaming it to tep_image_original

 

then put

 

if (substr($src, -4) == '.swf') return tep_image_original ($src, $alt, $width, $height, $params);

 

at the start of the new function

 

Oh got it!! That works a treat!! :)

 

It never even occurred to me to use the whole original function in it's entirety. I had actually tried my hand at writing a new function tep_swf by stripping down the original function and escaping the new function - but I was really making a mess of it and more complicated than it needed to be.

 

sorry, I though u knew what u were doing!!

 

HA HA! There are those days when i think i do, but then there are days like today...... :blush:

 

Hey spooks, thanks for taking the time to help me - I had already spent a day on this and was quite bleary-eyed, and if not for you I would be at it again today.

 

My best to you -

Link to comment
Share on other sites

sorry, I though u knew what u were doing!!

 

put back your original function, renaming it to tep_image_original

 

then put

 

if (substr($src, -4) == '.swf') return tep_image_original ($src, $alt, $width, $height, $params);

 

at the start of the new function

 

Hmmmm, this is going to need a little tweak -

 

The swf file "thumbs" are showing up just fine now, but on any pages that display them, i get a momentary flash of white and then the page loads. It seems as though ALL the images are getting parsed again. In Firefox, it only seems to occur on pages with swf - and in IE it happens on every page.

 

So close and yet...yet....

 

Any thoughts? Thanks so much!

Link to comment
Share on other sites

Hmmmm, this is going to need a little tweak -

 

The swf file "thumbs" are showing up just fine now, but on any pages that display them, i get a momentary flash of white and then the page loads. It seems as though ALL the images are getting parsed again. In Firefox, it only seems to occur on pages with swf - and in IE it happens on every page.

 

So close and yet...yet....

 

Any thoughts? Thanks so much!

 

Methinks me has it! :lol:

 

In the OTF tep_image function I removed the tidbit you originally suggested:

if (substr($src, -4) == '.swf') return tep_image_original ($src, $alt, $width, $height, $params);

 

moved it further down - to change this:

 

            // Scale the image if not the original size
           if ($image_size[0] != $width || $image_size[1] != $height) {
               $rx = $image_size[0] / $width;
               $ry = $image_size[1] / $height;

               if ($rx < $ry) {
                   $width = intval($height / $ratio);
               } else {
                   $height = intval($width * $ratio);
               }
               $image = '<img src="product_thumb.php?img=' . $src . '&w=' .
               tep_output_string($width) . '&h=' . tep_output_string($height) . '"';
           }

       } elseif (IMAGE_REQUIRED == 'false') {
           return '';
       }
   }

 

to this:

 

           // Scale the image if not the original size
           if ($image_size[0] != $width || $image_size[1] != $height) {
               $rx = $image_size[0] / $width;
               $ry = $image_size[1] / $height;

               if ($rx < $ry) {
                   $width = intval($height / $ratio);
               } else {
                   $height = intval($width * $ratio);
               }
           if (substr($src, -4) == '.swf') $image = '<embed src="' . $src . '"';
            } else {
               $image = '<img src="product_thumb.php?img=' . $src . '&w=' .
               tep_output_string($width) . '&h=' . tep_output_string($height) . '"';
           }

       } elseif (IMAGE_REQUIRED == 'false') {
           return '';
       }
   }

 

Initial testing seems to show that it covers all the bases and I don't even need to use the tep_image_original!

 

swf files seem to be resizing/displaying properly, regular images seem to be thumnailing properly, and there doesn't seem to be the white flash of blank page while the images reload.

 

~ Fingers crossed ~

 

Sam, I could have never done it without you giving me that snippet! Thanks a million!

 

Now, I'm still having an issue with IE - it reloads the images on EVERY page and I don't think it has anything to do with the OTF Thumbnailer. I uploaded a stock html_output file and it behaves the same way. I guess that's for another thread.

 

Thank you Sam again - I'll let you know if it blows up!

Link to comment
Share on other sites

Methinks me has it! :lol:

Aw, gee, I spoke too soon - once I cleared my cache the thumbnails ARE NOT displaying properly - ARGHHH!!

 

I think I'm on the right track though - maybe switching the order....

 

Sam, your original idea worked just fine except for that "iimage reloading thing"

 

OK, I'm gonna go drown my sorrows in a pint of ice cream and come back to this later.....

 

As always, thanks for your time -

Link to comment
Share on other sites

Aw, gee, I spoke too soon - once I cleared my cache the thumbnails ARE NOT displaying properly - ARGHHH!!

 

I think I'm on the right track though - maybe switching the order....

 

Sam, your original idea worked just fine except for that "iimage reloading thing"

 

OK, I'm gonna go drown my sorrows in a pint of ice cream and come back to this later.....

 

As always, thanks for your time -

 

Ok, I may be drunk with sugar but i think I may really have it this time - I ended up with this modification in the OTC tep_image function:

 

            // Scale the image if not the original size
           if ($image_size[0] != $width || $image_size[1] != $height) {
               $rx = $image_size[0] / $width;
               $ry = $image_size[1] / $height;

               if ($rx < $ry) {
                   $width = intval($height / $ratio);
               } else {
                   $height = intval($width * $ratio);
               }

               $image = '<img src="product_thumb.php?img=' . $src . '&w=' .
               tep_output_string($width) . '&h=' . tep_output_string($height) . '"';

           if (substr($src, -4) == '.swf') $image = '<embed src="' . tep_output_string($src) . '"';
           }

       } elseif (IMAGE_REQUIRED == 'false') {
           return '';
       }
   }

 

It seems to be working for now - I'll let ya know!

 

:blink:

Link to comment
Share on other sites

  • 2 months later...

Hi, all. I did an install of version 2.4 fix 4, and it works, but now when you click to enlarge the image you get the same image. I saw a post about this earlier, but no fix. Anyone know where the error is?

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