[wp-trac] [WordPress Trac] #15311: dynamic image resize (on the fly) using already available functions

WordPress Trac noreply at wordpress.org
Sat Jan 10 17:32:15 UTC 2015


#15311: dynamic image resize (on the fly) using already available functions
------------------------------------+-----------------------------
 Reporter:  vteixeira               |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Media                   |     Version:  3.1
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |     Focuses:
------------------------------------+-----------------------------

Comment (by ericlewis):

 Replying to [comment:104 markoheijnen]:
 > Personally I like my approach better where I only generating the missing
 image and not regenerate everything which is what
 `wp_generate_attachment_metadata()` does.

 Good point. `wp_generate_attachment_metadata()`
 [https://core.trac.wordpress.org/browser/tags/4.1/src/wp-
 admin/includes/image.php#L120 regenerates all image sizes] - yikes. In
 attachment:15311.7.diff, let's use the return from
 `image_make_intermediate_size()` to fill in the missing info on
 `$imagedata` more explicitly, and then hit
 `wp_update_attachment_metadata()`.

 Should/can we do anything about
 [https://core.trac.wordpress.org/ticket/21961#comment:3 scribu's race
 condition]? Essentially, should we worry about the same size being
 requested for generation 100x in a second to avoid server exhaustion.

 I could see setting a lock in post meta on the attachment. Say,
 `image_size_{size}_generating`, which is checked before generating, then
 set, then unset when the image is done generating. This could avoid a
 resource stampede, but creates more db queries.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/15311#comment:106>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list