Once we’ve defined the above image sizes (regular, medium and large) — and since by default WordPress doesn’t do it for us
— we’ll add the ability to select our those image sizes from the Attachment Display Settings interface.
It would be nice if you could, when writing a post, insert the desired size image by selecting it from the dropdown as you
normally would for the WordPress default sizes.
To do this, we add the following to our functions.php:
// show custom image sizes on when inserting media
function cake_show_image_sizes($sizes) {
$sizes['regular'] = __( 'Our Regular Size', 'cake' );
$sizes['medium'] = __( 'Our Medium Size', 'cake' );
$sizes['large'] = __( 'Our Large Size', 'cake' );
return $sizes;
}
add_filter('image_size_names_choose', 'cake_show_image_sizes');
With that in place, we can select our image sizes.
No comments:
Post a Comment