Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#30874 closed enhancement (duplicate)

adjust add_image_size generation point

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


There was a discussion in the WP Slack channel on the method of handling on the fly image generation using add_image_size as the whitelist for images that are allowed to be generated.

I'm aware this is a long outstanding issue... Related: #15311, #21295, #8599. This is my first stab at the approach discussed in the #feature-respimg channel. I sure my patch will need to be modified.


  • Only generate thumbnail, large, and cropped images on file upload.
  • allow on-the-fly image resizes through existing wp_get_attachment_() functions for sizes defined using add_image_size


Currently when a theme requests an image size that doesn't exist, WP runs through the image_get_intermediate_size function to get the closest match. My alteration is to first check if the $size string provided exists within the list of intermediate sizes. If so, generate that new size, update the attachment meta (so that future requests bypass this check entirely), and return the information as expected.

Attachments (1)

media.patch (1.3 KB) - added by drrobotnik 9 years ago.
modification to media.php to the image_downsize function

Download all attachments as: .zip

Change History (3)

9 years ago

modification to media.php to the image_downsize function

#1 @markoheijnen
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is an exact duplicate of #21295 since we both focus on the PHP side so when it tries to retrieve the image through our API. Only the location where we do this is a bit different. Also we both made the same mistake of not checking when the image is getting upscales. I need to check how our patches behave in that situation.

And #15311 is now more focussing on generating the image when the url gets requested.

#2 @drrobotnik
9 years ago

#15311 appears to have been revived since I opened this ticket and is getting the traction I was hoping for :) Thanks!

Note: See TracTickets for help on using tickets.