Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Is there a way to search for product images that are no longer linked?

Is there a way to search for product images that are no longer linked?

2 Jul 2013, 4:53 PM
#1
beyre avatar

beyre

Zen Follower

Join Date:
Feb 2009
Posts:
422
Plugin Contributions:
0

Post #1 by beyre

Long story short, I have reconnected with a client who has a very large online store. At one point, when I wasn't in charge of it, there were too many inexperienced hands in the pot and product images (and other kinds of images) were saved all over the place within the website's file structure (inside and outside of the cart's files).

Is there ANY script/program/suggestion to run on the website to get a list of image files that are currently no longer linked (whether static images, product images, category images, website banners, etc etc - any kind of image anywhere on the site). I need to clean up the site's storage and also the bloated database.

I know there are easily 100s of images that are no longer being used, but because people didn't name images correctly (to easily identify them) and many were placed in the site's root ... I have no idea which ones are being used or not.

I know I'll have to almost literally go through each of the store's 5,500+ products and check to see where the product images were saved (as I had setup up sub-folders to sub-divide product images, but no one continued to do that) ... and moved and re-link those product images that were uploaded to the wrong places.

Any ideas would be greatly appreciated.

2 Jul 2013, 6:24 PM
#2
beyre avatar

beyre

Zen Follower

Join Date:
Feb 2009
Posts:
422
Plugin Contributions:
0

Post #2 by beyre

Just wanted to thank the mod who edited my thread title. My mind is going a mile-a-minute trying to work on this client's store, getting it back to where it should be in the rankings (they significantly dropped during my 2 year absence from being their webmaster). I meant to go back and finish my brain fart for the thread title, but forgot! LOL Thanks again.

3 Jul 2013, 2:10 AM
#3
beyre avatar

beyre

Zen Follower

Join Date:
Feb 2009
Posts:
422
Plugin Contributions:
0

Post #3 by beyre

Anyone?

I'm slowly going through the product images one by one as I update each product's meta tags.

Slowly .....

I did notice that additional images are not being deleted when a product is deleted (only the product's main initial image). Image Handler 2 is installed and used on this cart. I guess that's alright. I have Filezilla open and as I delete the pictures from my side (my computer), I'm making sure the main image is deleted from the site and also delete the additional images. Just curious as to why they are not deleting when the product is deleted.

3 Jul 2013, 2:28 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #4 by gjh42

No idea about IH functionality, intended or actual, but as additional images are not associated programmatically but merely recognized when searched for by naming conventions, it would be significantly more time-consuming as well as potentially overreaching to delete all images that fit the "additional" profile for a product's main image when deleting that image. The "delete matching additional images" function could be written, but obviously wasn't in the initial setup for whatever reasons there were.

3 Jul 2013, 2:41 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #5 by drbyte

Not sure if this is useful to your situation: http://www.zen-cart.com/downloads.php?do=file&id=1331

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Jul 2013, 2:59 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #6 by drbyte

Or this one, which I've just packaged and submitted after retrieving from some very old archives:
http://www.zen-cart.com/downloads.php?do=file&id=1690
(Consider it beta and untested)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Jul 2013, 3:36 AM
#7
beyre avatar

beyre

Zen Follower

Join Date:
Feb 2009
Posts:
422
Plugin Contributions:
0

Post #7 by beyre

Glen - Thank you for the IH2 info. =)

DrByte -

The 1st script you referenced, while not related to what I am currently doing, is extremely helpful later on down the process. The store has well over 5000 products ... it would be nice to know if any of them are missing their product image.

I am currently going through categories/sub-categories that are no longer being used, meticulously deleting the products and their images ... and have found a few that didn't have a product image to begin with.

The 2nd script you referenced sounds exactly up my alley. But, since you say it has been untested ... and I don't have the best of luck with untested anythings ... I'll continue my slow path until someone(s) has/have tested your script.

Thanks to the both of you for your help. I'll bookmark this thread.

3 Jul 2013, 6:42 AM
#8
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,779
Plugin Contributions:
2

Post #8 by picandnix

Why not run full backup then test the Doc's script? if it fails (I bet it won't) then simply restore DB and or files.

3 Jul 2013, 4:46 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #9 by gjh42

The Image Purge Utility sounds like a great thing for a busy store to have. One question: does it delete additional images (which are not listed anywhere as belonging to a specific product)? Or does it try to match them with a "listed" product image before flagging/deleting?

3 Jul 2013, 6:26 PM
#10
long_john avatar

long_john

New Zenner

Join Date:
Dec 2011
Posts:
19
Plugin Contributions:
0

Post #10 by long_john

I have ran this script on a website and it looks like all the additional images are flagged as orphans.
It would be nice to find a way around this.

3 Jul 2013, 8:52 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #11 by gjh42

It should be possible to adapt the code that looks up additional images for use, to make something that looks for files matching/extending listed product images and builds an array of additional names. It might take a lot of processing to run, but if only used in the backend at quiet times that may not be a problem.

5 Jul 2013, 5:20 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #12 by drbyte

DrByte:

Or this one, which I've just packaged and submitted after retrieving from some very old archives:
http://www.zen-cart.com/downloads.php?do=file&id=1690
(Consider it beta and untested)

The plugin has been updated.
I've done some updating to make it easier to use -- no more entering database credentials or email addresses etc.

It's tested* and does what it does just fine. Lots of ways to improve it yet, including subdirectory support and matching orphans with additional-images, etc.

Note: I just realized I've not actually tested its orphan-deletion part, only the reporting mode.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Jul 2013, 2:13 AM
#13
mcpisik avatar

mcpisik

Zen Follower

Join Date:
Jan 2007
Location:
Mount Maunganui, New Zealand
Posts:
417
Plugin Contributions:
0

Post #13 by mcpisik

Thanks for updating this mod Dr Byte.
I've used it today, and was just wondering if there was something I could add, to make it check the LRG folder as well as the main image folder?
(I spotted it wasn't setup for sub directories yet, but just hoped MED and LRG might be different or easy to check)
Thanks again.