Skip to content

Instantly share code, notes, and snippets.

@brentini
Last active March 23, 2018 21:43
Show Gist options
  • Save brentini/438c57917f1a4c350b90f39501c70744 to your computer and use it in GitHub Desktop.
Save brentini/438c57917f1a4c350b90f39501c70744 to your computer and use it in GitHub Desktop.
Wordpress - set custom image size in Media Library #wordpress
/* 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