Last active
November 27, 2020 00:27
-
-
Save 16am/6564251 to your computer and use it in GitHub Desktop.
Remove original size image from WordPress Upload Directory after upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment