Skip to content

Instantly share code, notes, and snippets.

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 hirejordansmith/e29e2906c8dfecad0dc5 to your computer and use it in GitHub Desktop.
Save hirejordansmith/e29e2906c8dfecad0dc5 to your computer and use it in GitHub Desktop.
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