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

Enhance webp_uploads_pre_generate_additional_image_source filter to support returning filesize value #333

Closed
Tracked by #22
felixarntz opened this issue May 13, 2022 · 0 comments · Fixed by #334
Closed
Tracked by #22
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Milestone

Comments

@felixarntz
Copy link
Member

Follow-up to #307: As identified by @mitogh in #318 (review) and then further discussed in #160 (comment), we should allow developers to optionally return the file size of a custom generated additional image source when using the webp_uploads_pre_generate_additional_image_source. This is crucial for implementations where e.g. the image is hosted in a CDN, which would mean that calling filesize() on a path would not be feasible.

It is probably best to make the filesize field optional, for two reasons:

  • To not break any existing filter usage, because the current version of the filter will already be released as part of plugin version 1.1.0.
  • To keep things simpler for plugins that do generate files within the WordPress environment, in which case WordPress can just call filesize() on the path returned.

Since the path returned is only relevant for calling filesize(), I suggest we implement the change as follows:

  • Continue to require the file key to be included in the array.
  • In addition to that, require either path or filesize to be included in the array.
  • In case of path, keep calling filesize() on it like today.
  • In case of filesize, use that value as is to return it within the result array.
@felixarntz felixarntz added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] Images Needs Dev Anything that requires development (e.g. a pull request) [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels May 13, 2022
@felixarntz felixarntz added this to the 1.2.0 milestone May 13, 2022
@eugene-manuilov eugene-manuilov self-assigned this May 13, 2022
@eugene-manuilov eugene-manuilov removed the Needs Dev Anything that requires development (e.g. a pull request) label May 13, 2022
@eugene-manuilov eugene-manuilov removed their assignment May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
2 participants