EZ thumbnails

Locked

Started by paulm on 2 Oct 2006, 11:16 PM · Views: 13,691

Results 1 to 20 of 48
This thread is locked. New replies are disabled.
2 Oct 2006, 11:16 PM
#1
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

EZ thumbnails

Since the Image Handler does a lot more than I need, I am writing a simple script that automaticly creates thumbnail images. Since I have some working sample code it's probably easy to do, but I was wondering if it hasn't been done before?

I did a quick search, but did not find any other automatic thumbnail creation module (only IH2). Am I overlooking something maybe?

3 Oct 2006, 8:30 AM
#2
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: EZ thumbnails

Hi paulm,
Nice news! I am also writing a simple image-thumbnail script based on Thumbnail class from teckis.
But I have not enough time to issue it as the module. :(

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Oct 2006, 9:04 AM
#3
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Hi Andrew,

nice to hear you had a similar idea.

No problem that you do not have time, because I think I can finish (and release?) my first version today (could even do it now), as it already works.

I am still working on it though to:

  1. test
  2. clean up code move settings to config files (maybe to database later)
  3. see if I can/should add any basic features
  4. add error handling
  5. decide where to store the thumbnails

If to be released it also it would need some documentation (but on that part time is the issue for me too, writing docs in English ....)

No core code changes will be needed for installation! (thanks to the hook the devs added to the 1.3.5 html_ouput file for image handlers :thumbsup: :-) ).

Currently my main concern is where to store the thumbnails, but on the other hand that is easy to change at any stage so maybe I should just pick a dir and see how it goes.

3 Oct 2006, 4:20 PM
#4
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: EZ thumbnails

I statically generate small and medium images in admin. And nothing changes in catalog scripts.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Oct 2006, 7:48 PM
#5
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Ah, staticly, that is a totally different approach than my script.

Mine works dynamicly. It even creates subdirectories in the images folder automaticly if needed (for images that reside in subdirectories of the images folder). Not 100% sure if this part works on all servers though, only tested it on my own server until now.

If you, or anyone else, would like to test it I can e-mail my current version.

11 Oct 2006, 12:36 PM
#6
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

On request I attached the script to this post. Please keep in mind that this is an "alfa/WIP" release! No doc is included, try on a testshop first, review the code and use and own risk!

Just copy the contents to your catalog dir, if needed chmod the thumnails/ dir so it's writable for the script, and see if it works. No code changes required for installation.

To check if it really works browse your shop and right click on thumnails to view the properties and/or check if the thumbnails/ dir is being filled with thumbnails.

11 Oct 2006, 2:53 PM
#7
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Oops, I added the required thumbnails/ dir just before I uploaded the script. Of course to the wrong location.... :blush:

I added includes/images/thumbnails/ while it should have been images/thumbnails/ (so it's just a subdir of the existing images dir).

The zip below should have the folder at the right location....

11 Oct 2006, 3:14 PM
#8
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Another oops. The package somehow contained an older version ....

Note that if you have IH (Image Handler 2) installed it needs to be uninstalled first! I will add an if function exists probably, but until then having both install will result in an error.

Corrected verion attached again.

11 Oct 2006, 4:48 PM
#9
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

I had an old IH version installed myself, and please be sure to remove all (catalog) IH files, and replace by the original Zen Cart files, since a lot of files are overwritten by the old IH version (no idea about the newer IH2).

12 Oct 2006, 12:57 PM
#10
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

New version. Probably/hopefully it's final (ftb, except for bug fixes) since it does everything I need myself for now :P

  1. Removed some debugging lines which I forgot to remove the previous version (some unused POST en SESSION vars).

  2. Added "Safe Mode" usage option, which is true by default. In "Safe Mode" subdirectories (like images/dvd/ for an image like images/dvd/a_bugs_life.gif) are not created automaticly, you need to create those yourself. Not really EZ... I know :wink2: (the option to do this automaticly is still available though). If you never put your images in subdirs of the images/ dir, or after the subdirs are created, it will make no difference.

  3. Added a small readme.txt file which hopefully explains how it works.

  4. Modified the code so that no error message will show if subdirectories do not exist and can not be created. That way you can chmod the thumbnails dir at any time to make it unwritable, without the risk of error messages to be shown.

  5. Upgraded version number to 1.0 :smartass:

10 Jan 2007, 6:17 PM
#11
toosquare avatar

toosquare

New Zenner

Join Date:
Jul 2005
Posts:
26
Plugin Contributions:
0

Re: EZ thumbnails

Hiya will this work with 1.37? Im interested in an IH replacement as it never seems to work right for me.

Thanks

10 Jan 2007, 7:25 PM
#12
toosquare avatar

toosquare

New Zenner

Join Date:
Jul 2005
Posts:
26
Plugin Contributions:
0

Re: EZ thumbnails

This seems to work on a clean install of 1.37 but doesnt seem to work with sefu that just works html_output file. Anyone else get this to work.

11 Jan 2007, 11:31 AM
#13
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

With "sefu" you mean a sefu mod? If so, do you have a link?

(not promising anything, but i am suprised something like sefu influences this mod so I might take a look)

11 Jan 2007, 4:32 PM
#14
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Hi,

I received your modified html_ouput.php file but it appears not to be up to date with 1.3.5/1.3.6/1.3.7! An important part of the 1.3.5+ code is missing in your html_ouput file.

After this part

    if (!file_exists($src)) {
      $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
    }

There should be this:

    // hook for handle_image() function such as Image Handler etc
    if (function_exists('handle_image')) {
      $newimg = handle_image($src, $alt, $width, $height, $parameters);
      list($src, $alt, $width, $height, $parameters) = $newimg; 
    }

    // Convert width/height to int for proper validation.
    // intval() used to support compatibility with plugins like image-handler
    $width = empty($width) ? $width : intval($width);
    $height = empty($height) ? $height : intval($height);

I won't guarantee it will work after adding it, since I have no idea about the other 25 differences in the file you sent compared to the standard 1.3.7 version of html_ouput.php.

13 Jan 2007, 8:47 PM
#15
toosquare avatar

toosquare

New Zenner

Join Date:
Jul 2005
Posts:
26
Plugin Contributions:
0

Re: EZ thumbnails

I added this bit into the html_output and it now seems to work.

It appears to generate the thumbnails on the fly as they are requested, does it do this just the first time an image is asked for? ( this might be a dumb question )

Thanks again!

15 Jan 2007, 8:44 PM
#16
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Yep, it creates the thumbnails on the fly, and only if the thumbnail does not exist yet. If the thumbnail already exists the script won't create one.

And it's not a stupid question (unless the readme or this thread already explains :P but I don't remember if I explained it here or in the readme)

25 Aug 2007, 4:25 PM
#18
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: EZ thumbnails

paulm:

Uploaded v1.01 to the downloads.

Uploaded to "Other Modules":
http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=704

Can you please explain the upgrade path from IH2 to this mod? It will also help to explain the difference between how this work versus IH2. I really like that your version does not mess with a lot of core file like IH2 does.

Currently with IH2 images are uploaded to the image folder and IH2 does the rest. IH2 also handles things like image.gif, image_01.gif, image_02.gif. By this I mean if this 3 images are uploaded to the image folder on the server, image handler with automatically assign image.gif as the default image and the other two images as additional images. How does this mod work.

How does this mod affects Medium and Large image folder. Currently IH2 doesn't use Zen Cart logic for Medium and Large image folder. A store owner simply need to upload their biggest image to image folder and IH2 handles the rest. How does this mod handle medium and large image?

How is this going to affect various mods like google base, ebay turbo lister, that needs to generate image url.

The readme file doesn't have much in it for explanation of the logic behind this mod.

Thanks for this contribution. This might be a nice replacement since Tim is no longer here to support IH2.

25 Aug 2007, 9:17 PM
#19
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: EZ thumbnails

Can you please explain the upgrade path from IH2 to this mod?I don't know IH2 very well, and I think "upgrade" would not be the right word. To swap I would totally remove IH2 (don't ask me how) first, then check that everyting works normal again, and then install this contribution.
image handler with automatically assign image.gif as the default image and the other two images as additional images. How does this mod workSomeone reported that this mod does not support the Zen extra images logic. I don't use the Zen extra images code myself because the way it works is not practical in my case, I disabled it a long time ago to prevent issues (not with this mod, but other unrelated issues I had with the naming convention). So I don't have any experience with the combination of the Zen extra images and this script.

How does this mod affects Medium and Large image folder. Currently IH2 doesn't use Zen Cart logic for Medium and Large image folder. A store owner simply need to upload their biggest image to image folder and IH2 handles the rest.It's about the same with EZ thumbnails. Al thumbnails are saved into a subfolder of images/ (images/thumbnails/ for products, images/thumbnails/categories/ for categories). The Zen folders are not being used. The store owner only uploads the large images (which will be used without modification). Note that the thumbnails folder has to be writable for this, and I am not sure about the security issues this might invoke. On shared servers it might be a bad idea to leave the folder writable?

How is this going to affect various mods like google base, ebay turbo lister, that needs to generate image url.I don't know. The the url's of the original images stay the same, so I guess the mods will continue to work.

The readme file doesn't have much in it for explanation of the logic behind this mod.That's true. It's mainly because I wrote it for my own usage. I just like to share code (most of the time), but I don't like writing readme's and I don't always have time and/or feel like supporting it fully. But I am glad you asked these questions, and I hope this helps others to understand what the script does.

This might be a nice replacement since Tim is no longer here to support IH2.For some it may. IH2 has lots of features and does a lot more than this mod does. So this mod wil certainly not be a nice IH2 replacement for everyone. **EZ Thumbnails only creates thumbnails on the fly automaticly, that's all. **Also my support will probably be very limited and is certainly not guaranteed.

An avarage PHP coder should however be able to figure out any issues him/her self, the code is short, simple and documented :-)

Also it might be a nice basic script to start with for someone that wants to write a more advanced automatic thumbnail creation script.

14 Sep 2007, 12:41 AM
#20
dinosoup avatar

dinosoup

New Zenner

Join Date:
May 2007
Posts:
17
Plugin Contributions:
0

Re: EZ thumbnails

First off, thank you very much for this contribution paulm. :-) This is just what I need.

However, I found something, not sure if it's a bug or intentional. When I set "Image - Use Proportional Images on Products and Categories" to false in the backend, then EZ thumbnails does not seem to kick in.

Anyways, thanks again.