X

Add custom image sizes to media insert dialog box with image_size_names_choose

Longer content tends to rank higher in search engines

With this little snippet you can add custom image sizes to media insert dialog box. image_size_names_choose allows modification of the image size lists so that you can place a custom option within the media library.


( Example: screenshot )

Code Snippet:


if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'new-size', 300, 100, true ); //(cropped)
}

add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
$addsizes = array(
“new-size'' => __( “New Size'')
);
$newsizes = array_merge($sizes, $addsizes);
return $newsizes;
}

Comments  Leave a Reply

  1. 25 WordPress Code Snippets for Enhanced Performance - ManageWP April 9, 2014 at 11:20 am

    […] Source […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!