Last active
March 23, 2018 21:43
-
-
Save brentini/438c57917f1a4c350b90f39501c70744 to your computer and use it in GitHub Desktop.
Wordpress - set custom image size in Media Library #wordpress
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
/* Custom image sizes to Media Library */ | |
function wp_70048_remove_image_sizes( $sizes ) { | |
unset( $sizes['thumbnail'] ); | |
unset( $sizes['medium'] ); | |
unset( $sizes['large'] ); | |
unset( $sizes['full'] ); | |
return $sizes; | |
} | |
add_filter( 'image_size_names_choose', 'wp_70048_remove_image_sizes' ); | |
add_filter( 'image_size_names_choose', 'my_image_sizes' ); | |
function my_image_sizes( $sizes ) { | |
$addsizes = array( | |
"singleinside" => __( "Inside Wide Image" ), | |
"singlesixteen" => __( "Inside Normal Image" ), | |
"singleportrait" => __( "Inside Portrait Image" ), | |
"medium" => __( "Small Square Image" ) | |
); | |
$newsizes = array_merge( $sizes, $addsizes ); | |
return $newsizes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment