Created
November 4, 2014 11:16
-
-
Save hirejordansmith/e29e2906c8dfecad0dc5 to your computer and use it in GitHub Desktop.
Add Custom Image Size & Connect Custom Images sizes to WordPress
This file contains 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 | |
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