Created
September 24, 2019 17:37
-
-
Save proweb/ab2076218395a81105160f9b6d4fc248 to your computer and use it in GitHub Desktop.
Remove WordPress images sizes - all except thumbnail
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
<?php | |
add_action( 'after_switch_theme', 'theme_activated' ); | |
add_filter( 'intermediate_image_sizes_advanced', 'remove_default_sizes'); | |
function theme_activated() { | |
// Set thumbnail size in settings > media. | |
update_option( 'thumbnail_size_w', 150 ); | |
update_option( 'thumbnail_size_h', 150 ); | |
update_option( 'thumbnail_crop', 1 ); | |
// Set medium size in settings > media. | |
update_option( 'medium_size_w', 0 ); | |
update_option( 'medium_size_h', 0 ); | |
// Set large size in settings > media. | |
update_option( 'large_size_w', 0 ); | |
update_option( 'large_size_h', 0 ); | |
} | |
function remove_default_sizes( $sizes) { | |
unset( $sizes['medium']); | |
unset( $sizes['large']); | |
unset( $sizes['medium_large']); | |
return $sizes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment