tags:

views:

69

answers:

2

In Wordpress Media Settings the Thumbnail size we can crop thumbnail to exact dimensions.

But for the Medium size no option to get exact dimensions. There have a way to force exact dimensions for medium size?

If yes, how to implement to the functions.php

A: 

Add this to your functions.php:

add_action( 'init', create_function( '', 'add_image_size( "cropped_medium", 300, 150, true );' ) );

The arguments are size name, width, height, and whether to force a crop.

John P Bloch
Parse error: syntax error, unexpected T_STRING in /functions.php on line 77
kampit
John forgot a comma between the `'init'` and the `create_function`.
Jan Fabry
+2  A: 

If you want medium images to be cropped instead of scaled, like you can choose for the thumbnail size in the options page (but not for medium or large sizes), you can set the medium_crop option to true in your functions.php:

if(false === get_option("medium_crop")) {
    add_option("medium_crop", "1");
} else {
    update_option("medium_crop", "1");
}
Jan Fabry
it's `===` thanks Jan. Lemme see the results
kampit
Yeah.. It's worked!. Thank you so much!
kampit
I wanted to be really certain :-) Remember that this will only affect **future** images, but not those that already exist.
Jan Fabry
This is definitely a better solution than mine. Cool solution Jan! :)
John P Bloch