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

Modern Image Formats: add AVIF output support #1176

Merged
merged 133 commits into from
May 29, 2024

Conversation

adamsilverstein
Copy link
Member

Summary

Add AVIF support for Modern Image Formats plugin.

Fixes #1151

Relevant technical choices

  • When the server supports AVIF, add a dropdown under settings->media where users can choose between AVIF and WebP as the output format
  • Slightly rename the field that enables generating JPEG images alongside the modern output format (so it isn't just about WebP plug JPEG).
    • note: I left the option name unchanged for backwards compatibility.
  • I removed the CSS class that were hiding part of the settings UI, that felt hacky and made adding the new field more challenging.

Screenshots

Media settings

The new settings fields on media, the new dropdown is only shown if AVIF is supported on the server:

image

note: the default selection is AVIF when available.

Uploads

  • Note: activate twenty-twentyone theme

Output set to AVIF

image

Output set to WebP

image

With "Also Output JPEGs" checked

AVIF

image

WebP

image

Note: there appears to be a bug when the additional JPEG option is selected. I will double check, I believe this problem is already present in trunk. Looking carefully at the final two images where this setting is enabled, the AVIF/WebP images are only generated in the default (small/medium/medium/large/large and -scaled) variations it looks like custom sizes and maybe the high dpi images are missing in the modern format. I can create a separate issue to investigate this further.

@adamsilverstein adamsilverstein added [Type] Feature A new feature within an existing module [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) no milestone PRs that do not have a defined milestone for release labels Apr 23, 2024
Copy link

github-actions bot commented Apr 23, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @phanduynam.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: phanduynam.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: joemcgill <joemcgill@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@adamsilverstein adamsilverstein changed the title Moder Image Formats: add AVIF output support Modern Image Formats: add AVIF output support Apr 23, 2024
plugins/webp-uploads/helper.php Outdated Show resolved Hide resolved
plugins/webp-uploads/helper.php Outdated Show resolved Hide resolved
plugins/webp-uploads/settings.php Outdated Show resolved Hide resolved
plugins/webp-uploads/settings.php Outdated Show resolved Hide resolved
adamsilverstein and others added 3 commits April 25, 2024 07:36
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
@adamsilverstein
Copy link
Member Author

It would be good to add some tests here. I was expecting existing tests to fail, since I changed the default output to AVIF - maybe the test runners don't have AVIF support.

plugins/webp-uploads/settings.php Outdated Show resolved Hide resolved
plugins/webp-uploads/helper.php Outdated Show resolved Hide resolved
plugins/webp-uploads/settings.php Outdated Show resolved Hide resolved
adamsilverstein and others added 2 commits May 28, 2024 07:14
Co-authored-by: Weston Ruter <westonruter@google.com>
# Conflicts:
#	tests/plugins/webp-uploads/load-tests.php
@adamsilverstein adamsilverstein removed the no milestone PRs that do not have a defined milestone for release label May 28, 2024
Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last minor requested changes!

tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
plugins/webp-uploads/settings.php Show resolved Hide resolved
tests/plugins/webp-uploads/load-tests.php Outdated Show resolved Hide resolved
Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing well for me. Pre-approving pending @weston's feedback

adamsilverstein and others added 9 commits May 28, 2024 16:22
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@adamsilverstein
Copy link
Member Author

🎉

"At least 1 approving review is required to merge this pull request."

@adamsilverstein
Copy link
Member Author

🎉

"At least 1 approving review is required to merge this pull request."

#1257 should let you approve this one @westonruter

@adamsilverstein adamsilverstein merged commit 2afa1dc into WordPress:trunk May 29, 2024
16 checks passed
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] Feature A new feature within an existing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AVIF support to the Modern Image Formats plugin
4 participants