Thread: Zen-Cart Images

Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Zen-Cart Images

    Howdy,

    It's been a while, and I haven't kept up with developments for Zen-Cart, so I'll ask this here (regarding a possible solution if it hasn't changed).

    Does Zen-Cart in the newest versions still dump all images into the single 'images' folder, making page loads slow if you have lot's of products and / or images?

    The slowdown in that case is (or was) caused by zen-cart looking through all the filenames in that folder to see if there were additional images to show.

    If this is still the case, is there a solution in the form of a plugin?

    If not, I put together a solution to that a long time ago for an old version of zen-cart, which might benefit other zenners, but no use going into it until the above is clear ;)

    Kind regards,
    Wouter

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Zen-Cart Images

    You can make all the subdirectories that you want in:
    /images

    then use directories like:
    /images/something
    /images/medium/something
    /images/large/something

    then when adding/editing Products you will see a dropdown:
    Upload to directory:

    and you have Main which is /images and the list of all subdirectories to choose from ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Zen-Cart Images

    Hi Linda,

    Thanks for the response.

    Maybe we mean different things, I know of the functionality, but that wouldn't speed up zen-cart's search for additional images that it does, in the same folder as where the main image is (usually just /images/).

    Well, unless you make a lot of separate folders, but that wouldn't be handy if you put up a lot of products.

    I'll describe the functionality I mean:

    Our site used to have around 6000 - 8000 products, so that was at least as many images (+ additional images), all in the /images/ folder.

    Page loadtimes were around 2.5 - 3 seconds, it felt okay, but one day I was testing and hadn't copied the image folder, and noticed that load speed was much faster.

    Eventually I understood that it was because Zen-Cart was looking through all those image filenames to find additional images to display, when it had an empty folder to work with, it was done in no time.

    I made a new folder structure in /images/, starting with /images/extra_images/.
    In that folder are folders starting with the 'thousand' count of the product id, so a product id of 500 will be in folder 0, product id 4599 will be in folder 4, etc.
    In those folders are subfolders with product id's, where the actual extra images go.

    Code changes make zen-cart look in extra_images to see if the thousandcount folder exists, if it doesn't it creates it, then it looks if a folder with the full product_id exists in that subfolder, if it doesn't, it creates it.

    If the product id folder did not exist, it will look in the main images folder for additional images, if it finds any it will move them to the product id folder.
    if the folder did exist, it will only look in that folder for additional images.

    That way, only the very first access of a product page is 'slow', all subsequent visits to that product page will only look for additional images in the product id's 'private' folder, where it wil either find no images, or just the images intended for that product.

    We went from the mentioned 2.5 - 3 second pageloads to sub-second pageloads, usually 0.3 - 0.7 seconds. We're now at about 17000-18000 products and the loadtime hasn't changed, I wouldn't want to think about what the loadtimes would be like otherwise..

    The main images stay in the normal /images/ folder in this setup btw, as they're not searched for, but directly accessed.

    I hope I've written this down in an understandable manner, I've tried to be as clear as I can be, but if not, do let me know. :)

    Is such functionality already available in new versions of Zen-Cart, or via plugin? If not, do you think a coderelease would benefit other Zen-Cart users?

    Edit: Just thought that maybe the speed increase was just because of a slow drivespeed at our hoster (though in most things they seemed speedy enough), and people on expensive hardware don't really have this problem to start with, but I suppose there are plenty of people running on slower hardware, or shared hosting.

    Kind regards,
    Wouter
    Last edited by Diavire; 22 Dec 2013 at 03:33 PM.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Zen-Cart Images

    There is nothing available that sorts additional images in sub-subfolders. Image Handler 4 may be fast and efficient for large product image counts, I haven't used it. You can get small file counts in folders without any code alterations if you just put the main images in subfolders, easy to do if you think to do it, so your solution is only needed if you want to put all main images in one massive /images/ folder.

    At any rate, your code might be very useful to some people, even as a base for experimentation, and it would be good to make it available.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,735
    Plugin Contributions
    17

    Default Re: Zen-Cart Images

    Quote Originally Posted by Diavire View Post
    Hi Linda,

    Thanks for the response.

    Maybe we mean different things, I know of the functionality, but that wouldn't speed up zen-cart's search for additional images that it does, in the same folder as where the main image is (usually just /images/).

    Well, unless you make a lot of separate folders, but that wouldn't be handy if you put up a lot of products.

    I'll describe the functionality I mean:

    Our site used to have around 6000 - 8000 products, so that was at least as many images (+ additional images), all in the /images/ folder.

    Page loadtimes were around 2.5 - 3 seconds, it felt okay, but one day I was testing and hadn't copied the image folder, and noticed that load speed was much faster.

    Eventually I understood that it was because Zen-Cart was looking through all those image filenames to find additional images to display, when it had an empty folder to work with, it was done in no time.

    I made a new folder structure in /images/, starting with /images/extra_images/.
    In that folder are folders starting with the 'thousand' count of the product id, so a product id of 500 will be in folder 0, product id 4599 will be in folder 4, etc.
    In those folders are subfolders with product id's, where the actual extra images go.

    Code changes make zen-cart look in extra_images to see if the thousandcount folder exists, if it doesn't it creates it, then it looks if a folder with the full product_id exists in that subfolder, if it doesn't, it creates it.

    If the product id folder did not exist, it will look in the main images folder for additional images, if it finds any it will move them to the product id folder.
    if the folder did exist, it will only look in that folder for additional images.

    That way, only the very first access of a product page is 'slow', all subsequent visits to that product page will only look for additional images in the product id's 'private' folder, where it wil either find no images, or just the images intended for that product.

    We went from the mentioned 2.5 - 3 second pageloads to sub-second pageloads, usually 0.3 - 0.7 seconds. We're now at about 17000-18000 products and the loadtime hasn't changed, I wouldn't want to think about what the loadtimes would be like otherwise..

    The main images stay in the normal /images/ folder in this setup btw, as they're not searched for, but directly accessed.

    I hope I've written this down in an understandable manner, I've tried to be as clear as I can be, but if not, do let me know. :)

    Is such functionality already available in new versions of Zen-Cart, or via plugin? If not, do you think a coderelease would benefit other Zen-Cart users?

    Edit: Just thought that maybe the speed increase was just because of a slow drivespeed at our hoster (though in most things they seemed speedy enough), and people on expensive hardware don't really have this problem to start with, but I suppose there are plenty of people running on slower hardware, or shared hosting.

    Kind regards,
    Wouter
    Quote Originally Posted by gjh42 View Post
    There is nothing available that sorts additional images in sub-subfolders. Image Handler 4 may be fast and efficient for large product image counts, I haven't used it. You can get small file counts in folders without any code alterations if you just put the main images in subfolders, easy to do if you think to do it, so your solution is only needed if you want to put all main images in one massive /images/ folder.

    At any rate, your code might be very useful to some people, even as a base for experimentation, and it would be good to make it available.
    Yes Image Handler (version 4 included) does use a cache system where sub-directories are created for images as the hash requires. There are a number sub-directories created to "temporarily" house each file and it's downsized version. There are a number of things that can be done to the file also to reduce it's size and to simplify presentation.

    I too think that an alternate means of storing files may be of benefit, at least if it does have an impact on processing/loading times. If it's something willing to share, there will be those that will do something with it.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Zen-Cart Images

    Quote Originally Posted by gjh42 View Post
    There is nothing available that sorts additional images in sub-subfolders. Image Handler 4 may be fast and efficient for large product image counts, I haven't used it. You can get small file counts in folders without any code alterations if you just put the main images in subfolders, easy to do if you think to do it, so your solution is only needed if you want to put all main images in one massive /images/ folder.

    At any rate, your code might be very useful to some people, even as a base for experimentation, and it would be good to make it available.

    Quote Originally Posted by mc12345678 View Post
    Yes Image Handler (version 4 included) does use a cache system where sub-directories are created for images as the hash requires. There are a number sub-directories created to "temporarily" house each file and it's downsized version. There are a number of things that can be done to the file also to reduce it's size and to simplify presentation.

    I too think that an alternate means of storing files may be of benefit, at least if it does have an impact on processing/loading times. If it's something willing to share, there will be those that will do something with it.

    I'll answer both Image Handler responses at once here.

    I think Image Handler is a plugin that simply cannot be missed from any Zen-Cart installation, even if just for image quality alone (browser's resizing solutions leave to be desired, to say the least), the pagesizes going down is a great, great benefit too, cannot applaud it enough.

    However, the subdirectories it makes have no impact on Zen-Cart's additional image seeking, since it looks for those image names first, and asks Image Handler if there are smaller cached versions of the images it finds afterwards, so with or without IH, it will waste that time searching, unless I misunderstood something you or gjh42 meant, or if I missed a function of IH4, since I have not used that yet.

    I'll try to collect the code soon, I'll have to dig through our site to see where all the bits are, it's been a while.

    I should note though, I have no idea how to write a plugin, so I would likely need help with that, also, the code might need to be updated for the later releases of Zen-Cart, something that would be difficult for me, since I don't have any stores running that.

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Zen-Cart Images

    Some basic info on plugin writing:
    http://www.zen-cart.com/content.php?...ion-submission

    IH will be beneficial for many or most but not all Zen Cart installations. Those with small numbers of products/images, and where the owner desires to individually control image sizes, do not need it and may actually be hindered by its automated features, and its added code complexity could be a liability if its features are not needed. If the owner is willing and able to submit small, medium and large versions of images, IH will not improve page size or speed.

    If you manually create subfolders for images with whatever criteria are needed to keep folder file counts low, there will be no significant performance loss in searching for additional images. Obviously if you have many thousands of images that may not be practical, and automated solutions come into their own.

 

 

Similar Threads

  1. Adding extra images to my zen cart
    By r1formetoo in forum General Questions
    Replies: 6
    Last Post: 7 Jan 2009, 09:04 PM
  2. Move zen cart product images
    By notoriousaudio in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 16 Nov 2008, 03:35 AM
  3. zen cart Images
    By a4tech in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 14 Apr 2007, 06:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR