Skip to content

Instantly share code, notes, and snippets.

@Hexodus
Last active August 2, 2017 09:36
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 Hexodus/48ab3f7e707f950c507aa96763b13c4c to your computer and use it in GitHub Desktop.
Save Hexodus/48ab3f7e707f950c507aa96763b13c4c to your computer and use it in GitHub Desktop.
Add custom images sizes to Wordpress and Admin area. Found solution here: https://havecamerawilltravel.com/photographer/wordpress-resize-thumbnails Place this code in your functions.php (i.e. in your child theme's folder)
<?php
add_image_size( 'homepage-thumb', 270, 175, false ); //soft crop = resize
add_image_size( 'search-thumb', 150, 150, true ); //hard crop
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'homepage-thumb' => __( 'Homepage Thumb' ),
'search-thumb' => __( 'Search Thumb' ),
) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment