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

WEBP image formats #810

Open
mgearh opened this issue Oct 18, 2021 · 4 comments · May be fixed by #1269
Open

WEBP image formats #810

mgearh opened this issue Oct 18, 2021 · 4 comments · May be fixed by #1269
Assignees
Labels
help wanted type:enhancement New feature or request.
Milestone

Comments

@mgearh
Copy link

mgearh commented Oct 18, 2021

Is your enhancement related to a problem? Please describe.

Yes, when distributing posts that are using a WEBP featured image, the image does not transfer.

Describe the solution you'd like

For the plugin to support the WEBP format.

Designs

Describe alternatives you've considered

Additional context

@mgearh mgearh added the type:enhancement New feature or request. label Oct 18, 2021
@jeffpaul jeffpaul added this to the Future Release milestone Oct 18, 2021
@meksone
Copy link

meksone commented Jun 23, 2022

Also SVG format doesn't being transfered.
Thanks

@willemb2
Copy link

It's 2024. All browsers support WEBP for some time now and AV1 is around the corner. IMHO it is essential to support those. WEBP already saves 42% in size on average compared to JPEG. Maybe that is why in #1144 the same issue is labelled as bug? 🤓
Why filter on file type at all? If it's in the Media Library WordPress will be able to handle it? But I'm no developer so this might be naive.

@benlk
Copy link

benlk commented Sep 8, 2024

Notes from the changeset https://core.trac.wordpress.org/changeset/50810 that implemented WebP support for https://core.trac.wordpress.org/ticket/35725, released in WP 5.8:

  • WP supports image/webp if function_exists( 'imagecreatefromwebp' ) or function_exists( 'imagewebp' )
  • MIME type is image/webp
  • extensions are .webp
  • related constants defined by PHP, or by WordPress as a fallback, are IMAGETYPE_WEBP and IMG_WEBP

Notes from current WordPress image support:

  • AVIF added WP 6.5.0, 'avif' => 'image/avif'
  • HEIC added WP 6.7.0, 'heic' => 'image/heic'

Other notes:

  • Distributor's minimum supported WordPress version is "6.4 or later" as of release 2.0.5, so we don't shouldn't have to worry that a sending or receiving version of Distributor is running on version of WordPress that doesn't support webp — We're probably fine to enable WebP by default
  • Distributor's minimum supported WordPress version does not rule out versions of WordPress that do not support AVIF/HEIC. Adding support for AVIF and HEIC may require some defensive coding to prevent sending HEIC or AVIF image files to an instance of WordPress/Distributor that doesn't support those files.
  • Distributor's filter name prefix is dt_
  • Distributor's allowed MIME types are at
    function get_allowed_mime_types() {
    return [
    'jpg|jpeg|jpe' => 'image/jpeg',
    'gif' => 'image/gif',
    'png' => 'image/png',
    'bmp' => 'image/bmp',
    'tif|tiff' => 'image/tiff',
    'ico' => 'image/x-icon',
    ];
    }
  • Distributor also has a dt_allowed_media_extensions filter which has a separate list of IDs
  • WordPress' filter for removing MIME types upload_mimes in https://developer.wordpress.org/reference/functions/get_allowed_mime_types/ uses the array format shown in the source of https://developer.wordpress.org/reference/functions/wp_get_mime_types/ of ['a regex' => 'mime/type', ...], which is the same format that 10up's filter uses.

@benlk
Copy link

benlk commented Sep 8, 2024

@meksone SVG support and integration with https://github.com/10up/safe-svg seems like it would be a separate issue, since WordPress does not natively support SVG. I've opened a separate issue to track that: #1268

@benlk benlk linked a pull request Sep 8, 2024 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type:enhancement New feature or request.
Projects
Status: Code Review
Development

Successfully merging a pull request may close this issue.

5 participants