#37730 closed defect (bug) (invalid)
Maybe image crop function problem on 4.6 version please check on function
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6 |
Component: | Media | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
I have developed many theme and plugin and most of them are used WordPress image crop function and it was working normally. But when I updated WordPress version 4.6, The WordPress image crop function is not working correctly in many of my plugin and theme. Example: when i gave
<?php add_image_size( 'cb_member_img', 300, 300 );
but when i upload images, then images are cropped as his wish, different times different sizes. I have uploaded 5/6 images, the images width are OK, But heights are different such as 241, 266, 214 etc. Here i uploaded images which are sized in width and height were 2000px/1500px.
I have used this code:
<?php function cb_member_thum(){ add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails', array( 'cb-team-member' ) ); add_image_size( 'cb_member_img', 300, 300 ); } add_action('after_setup_theme', 'cb_member_thum');
And calling function try:
<?php $cb_members_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'cb_member_img' );
or
<?php the_post_thumbnail('cb_member_thum');
and get function.
I mention it again that it was working before, but after updating WordPress 4.6, it was not working.
I think, it may be a problem in WordPress 4.6 image crop function. Please check. If problem will be found, fix this then next version updated will be released.
Thanks
Bashar
Hi @hmbashar and welcome to Trac,
Can you confirm that you're using this exact code,
add_image_size( 'cb_member_img', 300, 300 );
and expecting that the generated images would be300px
wide and300px
tall no matter what image is uploaded?By default
add_image_size()
will scale an image proportionally, so if you upload a 500x500px image it'll get scaled to 300x300px, but if you upload a 2000x1000px image it'll get scaled down to 300x150px.The 4th parameter can be set to cause the image to be cropped to the exact dimensions specified, the developer reference includes documentation on that parameter and valid settings.