Created
August 27, 2013 21:31
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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