Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Jun 2007
    Posts
    145
    Plugin Contributions
    0

    Default Identifying and Removing Redundant Images

    I sell, mainly, used books from my site. Whatever the item is I always upload an image of the actual item. I don't, currently, embed images in descriptions although this may be a possibility in the future. I only use stock images for brand new items.

    I'd like to be able to run a housekeeping process to identify and remove images for products that are disabled (I keep the description for the next time I have 'one of those' to sell) or products that have been deleted (there is another one already available or it's most unlikely I'll ever have another one).

    In the long term I'm talking about uploading, possibly, 300 to 500 images a month and - if the business grows as I hope - possibly into the 1,000's or even 10,000's. Sales will increase such that I'll need to remove, initially, small numbers (can be done manually) but increasing up to 1,000's per month (must be automated otherwise mistakes will happen).

    Clearly I'm going to have to do something about this before it gets out of hand.

    Does anyone know if such a tool already exists?
    We're now settled in at our final home - http://www.swiftbooks.co.uk - where you'll find an eclectic collection of used books. Still a lot of work to do, though!

  2. #2
    Join Date
    Jul 2006
    Location
    Cardiff, Wales
    Posts
    305
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    I know this is old but there's no answer and I too am having a problem...

    Over the years many, many images have built up on the server that are not used anymore. The site has thousands of products, but has thousands mor images.

    How can we remove old, unused images from the server without doing it manually, as it would take months. The sites uses too much disk space.

    Thanks

  3. #3
    Join Date
    Oct 2005
    Posts
    38
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    I ended up at this page looking for exactly the same solution. One of my clients adds and removes 20 products per week and has over 1100 products in their Zen Cart system but has over 2000 images on the server.

    They don't add images to the description and any other images used throughout the site are in a separate images directory.

    If someone could could suggest a MySQL command that can be run on the database to show a list of images currently in use, I'm quite happy to delete all the images not used manually.

  4. #4
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,739
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    If you use ez-populate to pull the products list it will have a column with the image filename for each product listed.
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  5. #5
    Join Date
    Jun 2007
    Posts
    145
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    I now have a housekeeping utility that:
    • reads the images directory
    • identifies and removes orphan images over n days old
    • identifies and reports orphan images less than n days old
    • reports images used by more than one product
    • ignores a list of 'untouchable' files

    It's rough and ready, but works for me on my UNIX server. The date handling will need to be reworked if you're on a Windows server.

    No guarantees, but you're welcome to a copy as a starter to meet your own requirements.

    UPDATED VERSION OF THE CODE IS POSTED IN THE PLUGINS AREA HERE: http://www.zen-cart.com/downloads.php?do=file&id=1690




    The attachment below is the old original code.
    Last edited by DrByte; 11 Jul 2013 at 05:18 AM. Reason: added link
    We're now settled in at our final home - http://www.swiftbooks.co.uk - where you'll find an eclectic collection of used books. Still a lot of work to do, though!

  6. #6
    Join Date
    Mar 2007
    Location
    Seattle, WA
    Posts
    159
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    I haven't done this, but I have seen a need for it and have given it a small amount of thought. An idea would be to build a PHP script external of Zencart. Make it looks something like...

    PHP Code:
    $sql="SELECT products_image FROM products WHERE products_status = 0";
    $sql_result=mysql_query($sql,$connection);
     
    while(
    $row=$mysql_fetch_array($sql_result))
    {
       
    unlink("store/images/$row[0]");

    I haven't actually built this, this is just the rough sketch of an idea I have in my head, but it could be a start to what you need.

  7. #7
    Join Date
    Jun 2007
    Posts
    145
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    Quote Originally Posted by jammin320 View Post
    I haven't done this, but I have seen a need for it and have given it a small amount of thought. An idea would be to build a PHP script external of Zencart. Make it looks something like...

    PHP Code:
    $sql="SELECT products_image FROM products WHERE products_status = 0";
    $sql_result=mysql_query($sql,$connection);
     
    while(
    $row=$mysql_fetch_array($sql_result))
    {
       
    unlink("store/images/$row[0]");

    I haven't actually built this, this is just the rough sketch of an idea I have in my head, but it could be a start to what you need.
    I admire your enthusiasm, but:

    a) It's already written and working, and,

    b) If you follow your own suggestion without thinking it through a lot more I do believe you will delete all of your images, if not more.
    We're now settled in at our final home - http://www.swiftbooks.co.uk - where you'll find an eclectic collection of used books. Still a lot of work to do, though!

  8. #8
    Join Date
    Mar 2007
    Location
    Seattle, WA
    Posts
    159
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    Quote Originally Posted by GSIS View Post
    I admire your enthusiasm, but:

    a) It's already written and working, and,

    b) If you follow your own suggestion without thinking it through a lot more I do believe you will delete all of your images, if not more.
    I absolutly agree that it would need work (thus my disclaimer) and your solution would be ideal for many. It is just another thought to add to the post. As written here however, it wouldn't delete all of the images, it runs a greater chance of not deleting any. The premis is solid, I have this basic login included in several tools that link into ZenCart currently and it works well. The advantage of something small like this is that it can be built into a custom page. Yours may as well...I haven't seen it.

  9. #9
    Join Date
    Jun 2007
    Posts
    145
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    Quote Originally Posted by jammin320 View Post
    I absolutly agree that it would need work (thus my disclaimer) and your solution would be ideal for many. It is just another thought to add to the post. As written here however, it wouldn't delete all of the images, it runs a greater chance of not deleting any. The premis is solid, I have this basic login included in several tools that link into ZenCart currently and it works well. The advantage of something small like this is that it can be built into a custom page. Yours may as well...I haven't seen it.
    I now see the product_status = 0 bit of the sql statement.

    Doesn't meet my requirements anyway as I need the image to hang around for a while.

    I think mine is best left as a stand-alone utility. I'm looking into running it as a cron job once a week so I don't have to think about it. It would be daft to have a computer and think for yourself.
    We're now settled in at our final home - http://www.swiftbooks.co.uk - where you'll find an eclectic collection of used books. Still a lot of work to do, though!

  10. #10
    Join Date
    Mar 2007
    Location
    Seattle, WA
    Posts
    159
    Plugin Contributions
    0

    Default Re: Identifying and Removing Redundant Images

    Quote Originally Posted by GSIS View Post
    It would be daft to have a computer and think for yourself.
    --Well said!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Problem identifying where to make change -removing Cross Sell
    By fiberphile in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 8 Jan 2012, 11:18 PM
  2. Changing and removing images...
    By Amy Chomas in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 5 May 2011, 05:28 PM
  3. Identifying (and deleting) unused images
    By pharry in forum General Questions
    Replies: 2
    Last Post: 16 Nov 2009, 10:03 PM
  4. Removing redundant category from product listing?
    By yelow in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 4 Nov 2008, 07:31 PM
  5. help removing banner image and styling product images
    By BoYgAB90 in forum Basic Configuration
    Replies: 4
    Last Post: 28 Aug 2007, 12:31 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