Skip to content

Enhance webp_uploads_pre_generate_additional_image_source filter to support returning filesize value #333

Closed

Description

@felixarntz

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.

Activity

  1. added this to the 1.2.0 milestone on May 13, 2022
  2. removed
    Needs DevAnything that requires development (e.g. a pull request)
    on May 13, 2022
  3. removed their assignment
    on May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions