Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#23779 new defect (bug)

Can't insert large image if it's smaller than media setting but larger than theme setting

Reported by: aaroncampbell's profile aaroncampbell Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: has-patch dev-feedback
Focuses: Cc:


If you upload an image that is larger than $content_width but not larger than the "large" setting in settings->media, the option to insert a "large" image into the post isn't available even though the image is large enough.

It looks like it must use $content_width as the actual width of the large image that's inserted, and the large_size_w setting to decide whether to show that option or not.

Attachments (2)

23779.diff (1.4 KB) - added by kovshenin 11 years ago.
23779.2.diff (1.4 KB) - added by kovshenin 11 years ago.

Download all attachments as: .zip

Change History (18)

#1 @SergeyBiryukov
11 years ago

If the uploaded image is smaller than Large size in media settings, the large size is not generated. Since wp_prepare_attachment_for_js() only fills in the sizes that actually exist for the image, the Large option is in unavailable in the dropdown.

Or am I missing something?

#2 @SergeyBiryukov
11 years ago

  • Keywords reporter-feedback added

#3 @aaroncampbell
11 years ago

  • Keywords reporter-feedback removed

When it creates the dropdown and when it inserts the image into the post it uses $content_width, a theme-defined global variable, if it exists.

To see what I mean, enable Twenty Twelve which uses $content_width = 625, and leave your media setting for large to the default 1024. Now upload an image that is wider than 1024 and you will get the option to insert the large image into the post but the width will be 625. Now upload an image that is 800px wide (or something between 625 and 1024) and you don't have the large option. Instead you have to insert the full-size and then resize it.

I've had several users that were really frustrated by this. The workaround is pretty easy (just set the media settings to match the theme), but it's not very obvious. They expect to be able to use the large option if the image they upload is larger than what they always see as the "large" option (which is $content_width).

#4 @nacin
11 years ago

  • Milestone changed from Awaiting Review to 3.6

This is really interesting. Took me a bit to fully understand it.

Is this reproducible in 3.4?

#5 @dfcowell
11 years ago

I was able to reproduce in trunk and 3.4.

Starting work on a patch.

Last edited 11 years ago by dfcowell (previous) (diff)

11 years ago

#6 @kovshenin
11 years ago

  • Keywords has-patch added
  • Version changed from 3.5 to 3.0

Reproduced in 3.0. 23779.diff uses the original image metadata if a size's metadata is not available, and performs a check before adding the size, to make sure we don't see duplicate sizes when full and large are equal.

#7 @nacin
11 years ago

  • Keywords 3.7-early added
  • Milestone changed from 3.6 to Future Release

Since this goes back a ways, moving to 3.7.

#8 @aaroncampbell
11 years ago

  • Keywords 3.7-early removed
  • Milestone changed from Future Release to 3.7

11 years ago

#9 @kovshenin
11 years ago

Refreshed in 23779.2.diff, still works as expected.

#10 @wikicms
11 years ago

  • Cc wikicms@… added

For example Twenty Twelve theme uses full-width template with $content_width = 960 also. And this width option do not show to us. It would be very good to select width (without manual resizing after uploads) when using custom templates.

Last edited 11 years ago by wikicms (previous) (diff)

#11 @nacin
11 years ago

It appears that 23779.2.diff would cause duplication. It's not just for the "large" size image, but for any additional image sizes that are larger than the content width but smaller than the uploaded image. Then what would happen is you'd have every image size listed as the same constrained width. Desired?

#12 @jlambe
11 years ago

  • Cc julien@… added

#13 @jlambe
11 years ago

If I understand, we should check if the original image width is between $content_width and a default 'thumbnail' - 'medium' and 'large' sizes and other custom sizes ?

So every defined sizes that have a higher value should default to the $content_width size as Nacin said.

So do we have to display the default 'thumbnail-medium-size' + those the user wants to display in the dropdown even if they have the same sizes ? or maybe set an "all-in-one" size name for all cases ?

#14 @nacin
11 years ago

  • Milestone changed from 3.7 to 3.8

This isn't a regression, is less straightforward than it initially seemed, and has some open questions. Let's solve it in 3.8.

#15 @nacin
11 years ago

  • Milestone changed from 3.8 to Future Release

Still has some open questions.

#16 @chriscct7
9 years ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.