Make WordPress Core

Opened 2 years ago

Last modified 15 months 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 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: has-patch
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 23 months ago.
23779.2.diff (1.4 KB) - added by kovshenin 18 months ago.

Download all attachments as: .zip

Change History (17)

comment:1 @SergeyBiryukov2 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?

comment:2 @SergeyBiryukov2 years ago

  • Keywords reporter-feedback added

comment:3 @aaroncampbell2 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).

comment:4 @nacin2 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?

comment:5 @dfcowell23 months ago

I was able to reproduce in trunk and 3.4.

Starting work on a patch.

Last edited 23 months ago by dfcowell (previous) (diff)

@kovshenin23 months ago

comment:6 @kovshenin23 months 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.

comment:7 @nacin20 months ago

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

Since this goes back a ways, moving to 3.7.

comment:8 @aaroncampbell19 months ago

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

@kovshenin18 months ago

comment:9 @kovshenin18 months ago

Refreshed in 23779.2.diff, still works as expected.

comment:10 @wikicms18 months 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 18 months ago by wikicms (previous) (diff)

comment:11 @nacin17 months 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?

comment:12 @jlambe17 months ago

  • Cc julien@… added

comment:13 @jlambe17 months 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 ?

comment:14 @nacin17 months 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.

comment:15 @nacin15 months ago

  • Milestone changed from 3.8 to Future Release

Still has some open questions.

Note: See TracTickets for help on using tickets.