when I upload in woocommerce image it uploads different sizes:

  1. For category
  2. Single
  3. Thumb

and keeps original file which is big... how can I auto delete this original file ?

closed as off-topic by gmazzap, Pieter Goosen, Nicolai, Johannes Pille, birgire Aug 24 '14 at 20:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – gmazzap, Pieter Goosen, Nicolai, Johannes Pille, birgire
If this question can be reworded to fit the rules in the help center, please edit the question.

  • In future, please post WooCommerce related questions to Stack Overflow with a tag of "Woocommerce" and not in this forum. – Pat Gilmour Aug 23 '14 at 23:52

You should be able to do this with the same filter that is talked about here.

The full-size images are being kept by WordPress. It's not really a WooCommerce thing. As well as the settings for images in WooCommerce you will also need to set minimum image size in WordPress's Settings>Media... Then this script (see the link above for complete discussion) should remove the originals.

add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );

function delete_fullsize_image( $metadata )
    $upload_dir = wp_upload_dir();
    $full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
    $deleted = unlink( $full_image_path );

    return $metadata;

Don't do it.

You will need the original images to regenerate the smaller version when you will want to change the theme, and disk space is so cheap there is no real need to conserve it.

A better alternative is to limit image upload size and force the user to photoshop the image before uploading, something that most likely will also improve the result of the automatic cropping.

  • At this moment I made smaller the original file :) Thanks for tips! – andys Aug 27 '14 at 11:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.