This allows you to create custom image sizes to be used throughout your files and also connects the custom images sizes that you create into WordPress, to be used throughout the admin section of the site in widgets, pages, posts, etc.
<?php | |
// Add Custom Image Sizes | |
add_action( 'after_setup_theme', 'setup_image_sizes' ); | |
function setup_image_sizes() { | |
if ( function_exists( 'add_image_size' ) ) { | |
add_image_size( 'example-name', 360,214,true ); | |
} | |
} | |
// Connect Custom Image sizes to Wordpress | |
add_filter('image_size_names_choose', 'post_image_sizes'); | |
function post_image_sizes($sizes){ | |
$custom_sizes = array( | |
'example-name' => 'Example Name', | |
); | |
return array_merge( $sizes, $custom_sizes ); | |
} | |
?> |
Leave a Reply