Skip to content

Instantly share code, notes, and snippets.

@psteinweber
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psteinweber/8933338 to your computer and use it in GitHub Desktop.
Save psteinweber/8933338 to your computer and use it in GitHub Desktop.
Register custom images sizes in wordpress functions.php and make them accessible via the media manager. #wordpress #php
/* ==========================================================================
Register image sizes
========================================================================== */
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'blog-featured', 940, 330, true ); // cropped
add_image_size( 'testimonial-thumb', 100, 100, false ); // not cropped
}
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'testimonial-thumb' => __('Testimonial thumb'),
'blog-featured' => __('Blog featured'),
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment