[wp-trac] [WordPress Trac] #49412: Store filesize media metadata

WordPress Trac noreply at wordpress.org
Tue May 11 19:34:37 UTC 2021


#49412: Store filesize media metadata
-------------------------------------------------+-------------------------
 Reporter:  Cybr                                 |       Owner:
                                                 |  johnwatkins0
     Type:  feature request                      |      Status:  assigned
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  refresh                                        |  performance
-------------------------------------------------+-------------------------
Changes (by azaozz):

 * keywords:  has-patch has-unit-tests => has-patch has-unit-tests needs-
     refresh


Comment:

 Replying to [comment:24 joemcgill]:
 > One of the questions that has come up in the past (which I can't find
 record of, for some reason) is how to sites that rely on plugins or
 services that optimize images in the background after they're uploaded so
 that WordPress isn't relying on inaccurate `filesize` data saved in
 metadata.

 Yeah that's the main drawback. Seems the best option is to rely on these
 plugins to do-the-right-thing and update the file size after post-
 processing.

 > I wonder if using transients for this (caching of filesize) would be
 useful and if doing so would reduce the need for explicit attachment
 metadata since `wp_filesize()` could check for a cached value before
 executing a filesize read?

 That will solve the problem with plugins not updating image meta after
 post-processing images, and with missing `filesize`. However transients
 should not be saved/updated from the front-end. There is the rule to never
 write to the DB from a front-end request for unidentified users. That can
 bring down busy sites quite easily.

 There are other cases where images are stored remotely. Then updating the
 meta after post-processing or trying to get the file size at runtime may
 not work.

 As far as I see the "assumptions" for the `filesize` meta would be that:
 1. It's optional, does not exist for older files.
 2. May be incorrect.

 Would it be useful to have it? Perhaps yes, depends... :) One use might be
 to drop image sub-sizes when generating `srcset`. Another is to speed up
 loading of the media modal/library.

 Any other usage that would still be acceptable after considering the above
 two points?

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


More information about the wp-trac mailing list