Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store file size (and other) media metadata #8

Closed
adamsilverstein opened this issue Nov 29, 2021 · 5 comments
Closed

Store file size (and other) media metadata #8

adamsilverstein opened this issue Nov 29, 2021 · 5 comments
Assignees
Labels
[Type] Enhancement A suggestion for improvement of an existing feature
Milestone

Comments

@adamsilverstein
Copy link
Member

At the moment, WordPress does not store the file (storage) sizes for uploaded files, or the sizes of media generated, in the database. At the moment, whenever WordPress needs to find out this information, it needs to read from the filesystem, or make remote requests in the case of a CDN. This keeps WordPress from using this information to make more informed decisions about responsive images or resizing in a performant fashion.

We should store file sizes as attachments are uploaded, and use this information in appropriate existing locations in core where file size is queried.

Trac ticket: https://core.trac.wordpress.org/ticket/49412

@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] Images labels Nov 29, 2021
@adamsilverstein adamsilverstein changed the title Store file size media metadata Store file size (and other) media metadata Dec 14, 2021
@jonoalderson
Copy link

jonoalderson commented Dec 15, 2021

Worth noting that there's often a read cost ($) associated with these types of remote lookups, depending on where/how the images are hosted.

@adamsilverstein
Copy link
Member Author

I updated the trac ticket with a refresh against trunk.

From the last comment from Andrew Ozz:

  • It will only be added for the "full" image size. This may not be the uploaded/original image file if the image was resized on uploading.
  • It may be missing or unreliable (if the image was optimized by a plugin after uploading), and will be used primarily as cache when displaying image info in wp_admin.
  • May be good to have some sort of a "backfill" functionality when filesize is missing. However that should happen "very sensibly". DB writes should be optimized (single write per page load) and happen only from wp-admin.

Leaving off the "backfill" for existing images could also be left for a second phase, it could probably happen naturally as a part of image regeneration.

@mitogh mitogh self-assigned this Jan 17, 2022
mitogh added a commit that referenced this issue Feb 21, 2022
For every single image size a new mime type would be created
if the original mime type of the image supports the specified
mime type.

Currently this only works with: `image/jpg` and `image/webp`
and vice-versa. Only for all the available image sizes except
the full size image.

This PR fixes: #142, #8
@eclarke1 eclarke1 added this to the 1.0.0-beta.1 milestone Feb 24, 2022
@eclarke1
Copy link

@mitogh @felixarntz can this issue also be closed as my understanding was that #147 also covered this issue? Please could you confirm?

@mitogh
Copy link
Member

mitogh commented Feb 25, 2022

That's correct @eclarke1 I wonder if we should create a new one to move the efforts from emerging the original PR into core at some point or if we should do it once the whole feature is merged there.

@eclarke1
Copy link

That's correct @eclarke1 I wonder if we should create a new one to move the efforts from emerging the original PR into core at some point or if we should do it once the whole feature is merged there.

Good question, this is something we may need to defer to @felixarntz on as there are a few other issues in a similar position I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants