I have a pretty basic question. It may be very noob question, but it is bothering me a lot. In my theme I've added a custom image size like this:
function img_update() {
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'blog_feat_img', 720 );
add_image_size( 'latest_posts_widget_feat_img', 400 );
add_image_size( 'portfolio_widget_feat_img_1x', 400 );
add_image_size( 'portfolio_widget_feat_img_2x', 800 );
add_image_size( 'blog_body_img', 740 );
}
}
add_action( 'after_setup_theme', 'img_update', 11 );
Now I used another function to add that in media dropdown list, like this:
function mytheme_image_size_names( $sizes ) {
$sizes['blog_body_img'] = __( 'Blog Body Image', 'isaumya' );
return $sizes;
}
add_filter( 'image_size_names_choose', 'mytheme_image_size_names', 11, 1 );
Everything fine but I'm having a wired issue. When Iupload an image of 1024x768
it should generate a 740x555
copy as I didn't mention the height, so it should take the proper height as per that width. But instead it is generating 650x488
version for blog_body_img
. I have no idea why. I've also tried to pass 0 as height and then true
as the crop parameter. Still it generates 650x488
version and not 740x555
. Why?
Can anyone help me out with this?
add_image_size( 'blog_body_img', 740, 600, true );
just for debugging purpose.add_image_size( 'blog_body_img', 740 );
, uploaded an image 1024x768 and I get a image size exactly of 740x555. Strange it is not working for you. Review your code and look for other possibleadd_image_size
you may have.