I’m using a lot of thumbnails but never the original file. To save space, I’d like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?

Thanks,
Dennis

7 s
7

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;
}

Leave a Reply

Your email address will not be published. Required fields are marked *