You need to register new custom image size.
to do that, open your functions.php file (inside theme folder).
Start by adding the support of post thumbnails (probably it is already supported, you maybe can skip this)
add_theme_support( 'post-thumbnails' );
Now you can use the functionality of registering additional image sizes you need like this:
add_image_size( 'your-image-size-name', 120, 120, true ); // Hard crop
add_image_size( 'your-image-size-name', 600, 400 ); // Soft crop
You need to chose some name for that size (thumbnail, medium, large and full are already taken, write anything else), and to set size (width, height), if you add “true” WP will resize exactly to that dimensions, not proportional.
To display that image size on your pages put this code in theme where you wish to display it:
<?php the_post_thumbnail( 'your-image-size-name' ); ?>
More info on:
http://codex.wordpress.org/Function_Reference/add_image_size
Thank you for replying.
I had read the wordpress section you linked to.
I had already carried out the first two parts of the instructions, but I am lost of the last bit.
When you say, “…put this code in the theme…” What do you mean? I want to be able to use the new sizes in blog posts, in the main content.
Thanks again.
Kim
Hi Kim.,
One you add the code in your theme. Add this plugin and regenerate new post thumbnails
https://wordpress.org/plugins/regenerate-thumbnails
Rajan V
This looks like what I want to do, but where oh where does it go?
For Media Library Images (Admin)
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’, ‘my_custom_sizes’ );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
‘your-custom-size’ => __( ‘Your Custom Size Name’ ),
) );
}
Ha ha – worked it out.
So, for anyone else like me who wants to create new image sizes accessible from the Media Library:
1. open your functions.php file (inside theme folder).
2. Add theme support by pasting in:
add_theme_support( 'post-thumbnails' );
3. Add image sizes by pasting in:
add_image_size( 'your-image-size-name', 120, 120, true ); // Hard crop
add_image_size( 'your-image-size-name', 600, 400 ); // Soft crop
4. Add to Media Library by pasting in:
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'your-custom-size' => __('Your Custom Size Name'),
) );
}
Further reading:
http://codex.wordpress.org/Function_Reference/add_image_size
http://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose
Hi again.,
Just put your theme function file (functions.php)
add_theme_support( 'post-thumbnails' );
add_image_size( 'your-image-size-name', 120, 120, true ); // Hard crop
add_image_size( 'your-image-size-name', 600, 400 ); // Soft crop
And Put this code where you want to display
<?php the_post_thumbnail( 'your-image-size-name' ); ?>