Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento 2 - Identify gallery image files missing from filesystem
mysql -u <user> -p <db> -h <host> -e "SELECT distinct case when value like '/%' then concat('.',value) else value end FROM catalog_product_entity_media_gallery" | awk '{print $1}' | xargs ls | grep "cannot access"
@rsisco
Copy link
Author

rsisco commented Nov 22, 2019

Run this command from within the Magento project's pub/media/catalog/product folder. Any image filenames listed are missing from the filesystem and could cause the image resize command within Magento to fail. The solution is to either replace the missing image file or delete its row from the catalog_product_entity_media_gallery table.

@molotovbliss
Copy link

molotovbliss commented Dec 17, 2019

BTW, just a note so I don't forget or someone else uses the snippet, it should be run under pub/media/catalog/product/ missing one folder.

@rsisco
Copy link
Author

rsisco commented Dec 18, 2019

BTW, just a note so I don't forget or someone else uses the snippet, it should be run under pub/media/catalog/product/ missing one folder.

Thanks; I've updated the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment