Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#37730 closed defect (bug) (invalid)

Maybe image crop function problem on 4.6 version please check on function

Reported by: hmbashar Owned by:
Priority: normal Milestone:
Component: Media Version: 4.6
Severity: normal Keywords: reporter-feedback
Cc: Focuses:

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

Change History (4)

#1 follow-up: @dd32
10 years ago

  • Component General → Media
  • Keywords reporter-feedback added

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 be 300px wide and 300px 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.

#2 in reply to: ↑ 1 @hmbashar
10 years ago

Replying to dd32:

Thanks for quick reply, I will check now.

Again Thanks and sorry for that wrong report.

#3 @Presskopp
10 years ago

  • Resolution → invalid
  • Status new → closed

#4 @netweb
10 years ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.