Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Remove redundant woocommerce product images WordPress

  • SOLVED

hi,

i am in the process of migrating my wordpress + woocommerce website locally to godaddy server but my problem is i have around 24000 product images, and it creates variants of each image we upload, now godaddy is not allowing to host more than 250,000 files, now my website is crossing that limit.

now my question is , is there any way i can find an delete unused product images in woocommerce ? a plugin or something ?

kindly advice asap i am struck in the middle of migration.

regards
Rajiv

Answers (2)

2014-07-17

Navjot Singh answers:

You can try this plugin: http://wordpress.org/plugins/image-cleanup/

Also go to the Media Tab and select unattached option and remove those images.


Navjot Singh comments:

There are two other such plugins: http://wordpress.org/plugins/cleanup-images/ and http://wordpress.org/plugins/dnui-delete-not-used-image-wordpress/ You can give them a try as well.

2014-07-18

timDesain Nanang answers:

image variation cleaner (tested) :
before: [[LINK href="http://i.imgur.com/K73PZhI.png"]]http://i.imgur.com/K73PZhI.png[[/LINK]]
after: [[LINK href="http://i.imgur.com/uLNRxlA.png"]]http://i.imgur.com/uLNRxlA.png[[/LINK]]


put this code in the theme's function.php:


add_filter( 'intermediate_image_sizes', 'wpq_image_cleaner' );

function wpq_image_cleaner( $sizes ) {
return array( 'medium', 'shop_thumbnail' );
}


to show all image variations

add_action('init', 'wpq_init' );
function wpq_init(){
echo '<pre>'; print_r(get_intermediate_image_sizes()); echo '</pre>';
}



then, rebuild the thumbnail and metadata db using this plugin:
[[LINK href="https://wordpress.org/plugins/force-regenerate-thumbnails/"]]https://wordpress.org/plugins/force-regenerate-thumbnails/[[/LINK]]
or
https://www.google.co.id/search?q=wordpress+force+regenerate+thumbnails


rajivvaishnav comments:

hi tim
how will this code help ? what does it exactly do ? i have around 24000 product images, how about timeout issue when running force regenerate thumbnails ?

pls explain about your code.


timDesain Nanang comments:

before: http://i.imgur.com/K73PZhI.png
wp have 6 image variants,
if you have around 24000 product images,
it will produce another 6 x 24,000 = 144,000
plus original image 1 x 24,000 = 24,000
= 168,000 image files

if your wp have 9 image variants (depend on theme and plugins that being activated)
then, you will have (9+1) x 24,000 = 240,000 image files

this code to show all image variants (have to disabled or delete before regenerate thumb processed):
add_action('init', 'wpq_init' );
function wpq_init(){
echo '<pre>'; print_r(get_intermediate_image_sizes()); echo '</pre>';
}



and
this code to limit the image variants
in this sample, it will limit medium and shop_thumbnail size only
you can change this part (be carefull to select the sizes)

add_filter( 'intermediate_image_sizes', 'wpq_image_cleaner' );
function wpq_image_cleaner( $sizes ) {
return array( 'medium', 'shop_thumbnail' );
}


then, you have to regenerate the thumbnail using plugin
and now it will produce 2 variants and 1 original images
so, your files will be: (2+1) x 24,000 = 72,000


the last:
"about timeout issue when running force regenerate thumbnails ?"
you can :
- regenerate partially : go to this page http://domain/wp-admin/upload.php
- or increase max execution time : https://www.google.co.id/search?q=php+set+ini+max_execution_time
- or report this issue (sorry about this): https://wordpress.org/support/plugin/force-regenerate-thumbnails


timDesain Nanang comments:

after put
echo '<pre>'; print_r(get_intermediate_image_sizes()); echo '</pre>';
to show all image variants: open new page (admin page or frontend)

try to regenerate some image files, then check the upload folder (wp-content/uploads/yyyy/dd/) that used by the images


timDesain Nanang comments:

hope this will help:

before: [[LINK href="http://i.imgur.com/3V28h3Z.png"]]http://i.imgur.com/3V28h3Z.png[[/LINK]]
27 variants image sizes, it will save 28 images (inc the original)

add a filter hooking to limit the variants:
add_filter( 'intermediate_image_sizes', 'wpq_image_cleaner' );
function wpq_image_cleaner( $sizes ) {
return array( 'medium', 'shop_thumbnail' );
}


then, regenerating: [[LINK href="http://i.imgur.com/czhe76b.png"]]http://i.imgur.com/czhe76b.png[[/LINK]]
Deleted: images with this size has been deleted
Regenerated: has been regenerated and saved

result/ after: [[LINK href="http://i.imgur.com/fS8RFD9.png"]]http://i.imgur.com/fS8RFD9.png[[/LINK]]
image variants shrink in to 2 sizes, it will save 3 images