Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 9 years ago

#24466 closed defect (bug) (invalid)

Custom image sizes display/insert with incorrect dimensions in media modal

Reported by: ericlewis's profile ericlewis Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Media Keywords:
Focuses: Cc:

Description

Something seems wonky in the backbone interface for media modals with a custom image size defined with hard cropping mode.

Drop this boilerplate in a plugin or theme. I dropped it into functions.php of Twenty Thirteen.

add_action( 'after_setup_theme', 'add_a_custom_image_size' );

function add_a_custom_image_size() {
	add_image_size( 'fat-and-short', 900, 300, true );
}

add_filter( 'image_size_names_choose', 'add_a_custom_image_size_to_media_modal', 10, 1 );

function add_a_custom_image_size_to_media_modal( $sizes ) {
	$sizes['fat-and-short'] = 'Fat and Short';
	return $sizes;
}

Then upload an image larger than these constraints in an Edit Post media modal. In the dropdown for attachment size, I see "Fat and Short - 604 x 201" - not the size defined. Even more bizarre, when the img element is inserted, it refers to the right file for the size (...-900x300.jpg), but the attributes on the image are set to the wonky dimensions.

Change History (4)

#2 follow-up: @ericlewis
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

After investigating a bit, I was testing with Twenty Thirteen here, which sets $content_width to 604, so this is actually expected behavior, not a bug. Marking invalid.

#3 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted

#4 in reply to: ↑ 2 @snarkypuppet
9 years ago

Replying to ericlewis:

After investigating a bit, I was testing with Twenty Thirteen here, which sets $content_width to 604, so this is actually expected behavior, not a bug. Marking invalid.

Hey could you elaborate on this? How does $content_width affect the image dimensions?

Note: See TracTickets for help on using tickets.