Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Custom Image Size & Connect Custom Images sizes to WordPress
<?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 );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.