Skip to content

Instantly share code, notes, and snippets.

@AMNDesign
Created August 27, 2013 21:31
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 AMNDesign/6359433 to your computer and use it in GitHub Desktop.
Save AMNDesign/6359433 to your computer and use it in GitHub Desktop.
Add custom image sizes to WordPress and make them available within the Media Library Attachment Display Settings options.
<?php
//* Add custom image sizes to WordPress
add_image_size( 'featured', 690, 180, TRUE );
add_image_size( 'full_width', 960);
add_image_size( 'grid', 300, 150, TRUE );
add_image_size( 'small_thumbnail', 100, 100, TRUE );
add_image_size( 'micro_thumbnail', 75, 75, TRUE );
//* Make custom sizes available within the WordPress Media Library Attachment Display Settings
add_filter( 'image_size_names_choose', 'amn_image_sizes_choose' );
function amn_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'featured' => 'Featured',
'full_width' => 'Full Width',
'grid' => 'Grid',
'small_thumbnail' => 'Small Thumbnail',
'micro_thumbnail' => 'Micro Thumbnail'
);
return array_merge( $sizes, $custom_sizes );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment