I am trying to achieve this look without going into a photo editing app and cutting and pasting the image to the exact size.

I don't mind if half the image is gone as long as we can retain that image dimension and the scale. enter image description here

  • How are you using/adding these images? Please add some kind of code. You should use thumbnails, then all images are with same dimensions + you don't need full size images in list: it would save a lot of bandwidth and would drastically decrease loading times. – N00b Jan 16 '16 at 5:39
  • 1
    Reading this should explain the basic knowledge behind uploading/adding media(images) and the standard 3 options for input (setting sizes) which wp offers out of the box. Next you could read this. And this is also a good source. As N00b also asked, what did you try, which code is used. Did you actually do some research yourself, if so, what is not clear. – Charles Jan 16 '16 at 5:45

Register a new image size with add_image_size( $name, $width, $height, $crop ).

// Hard crop left top

add_image_size( 'custom-size', 160, 90, array( 'left', 'top' ) );

Then use a plugin like Regenerate Thumbnails which will automatically create the new sizes on your server.

You can also make your custom sizes selectable from your WordPress admin. To do so, you have to use the image_size_names_choose hook to assign them a normal, human-readable name.

add_filter( 'image_size_names_choose', 'wpse_20160116_custom_sizes' );

function wpse_20160116_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'custom-size' => __( 'Your Custom Size Name' ),
    ) );

For featured images make sure to use add_theme_support( ‘post-thumbnails’ ); and then access the new size using the_post_thumbnail( $size, $attr ):

if ( has_post_thumbnail() ) { 
    the_post_thumbnail( 'custom-size' ); 

For other images you can use wp_get_attachment_image:

// Assuming your Media Library image has a post id of 42...

echo wp_get_attachment_image( 42, 'custom-size' );

As @Charles points out, you should be able to see your new size on the Media Settings Screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.