Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#22598 closed defect (bug) (fixed)

Not using image_downsize() in wp_prepare_attachment_for_js() can break esoteric usage

Reported by: nacin's profile nacin Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch commit
Focuses: Cc:

Description

If you disable all intermediate image sizes (so no images are created on upload), and then create them on the fly using the image_downsize filter (say, with a URL that can dynamically create images on the fly), our clever use of image metadata in wp_prepare_attachment_for_js() doesn't work.

We need to use image_downsize(). Preliminary patch attached.

If it is too slow for tons of prepares (and I imagine it may be), we may be able to fire the filter only, as long as the size exists in the metadata array for cases where the filter is not used.

Attachments (2)

22598.diff (1.6 KB) - added by nacin 12 years ago.
22598.2.diff (2.2 KB) - added by nacin 12 years ago.

Download all attachments as: .zip

Change History (8)

@nacin
12 years ago

@nacin
12 years ago

#1 @nacin
12 years ago

  • Keywords has-patch added

Second patch avoids image_downsize(). Best I can tell, we don't need any of the logic in image_downsize(), which consults the same metadata we do here and does a bunch of other things. We just need to know if a plugin wants to handle the downsizing, and if not, we can consult metadata.

#2 @koopersmith
12 years ago

  • Keywords commit added

Latest patch is stellar. It works and performs well.

#3 @ryan
12 years ago

Looks good.

#4 @ryan
12 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In 22850:

Make wp_prepare_attachment_for_js() compatible with plugins that disable all intermediate image sizes (so no images are created on upload), and then create them on the fly using the image_downsize filter (say, with a URL that can dynamically create images on the fly).

Props nacin
fixes #22598

#5 @nacin
12 years ago

In 23264:

Media: Pass thumbnail and medium sizes to image_constrain_size_for_editor() to force constraints based on the current DB options for those sizes. History: see #22598, #22738.

props jond3r.
see #23102.
for trunk.

#6 @ryan
12 years ago

In 23282:

Media: Pass thumbnail and medium sizes to image_constrain_size_for_editor() to force constraints based on the current DB options for those sizes. History: see #22598, #22738.

props jond3r
fixes #23102
for 3.5

Note: See TracTickets for help on using tickets.