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 ?

  • 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.