How to Delete all Unused photos Function
As a rule, I suggest you try to stick as much as possible to WordPress core functions when modifying the database, as they will handle associated data automatically – e.g. delete associated post meta, associated taxonomy info, etc. (Woocommerce stores product image data as product post_meta, see below for details.) This might slow things down … Read more