-
Notifications
You must be signed in to change notification settings - Fork 37
Convert images to optimized formats #50
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
Open
tijmenbruggeman
wants to merge
124
commits into
tinify:master
Choose a base branch
from
wcreateweb:task/format-conversion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Convert images to optimized formats #50
tijmenbruggeman
wants to merge
124
commits into
tinify:master
from
wcreateweb:task/format-conversion
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…task/format-conversion
…task/format-conversion
rkoopmans
reviewed
May 14, 2025
…task/format-conversion
…task/format-conversion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With file conversion enabled customers can choose to generate an additional image in a modern format. WebP and AVIF are known to produce a better quality and performance image. Unfortunately, not all browsers support it 100% so therefor we choose to supply it as an addition instead of replacing the image.
Changes
template_redirect
(https://developer.wordpress.org/reference/hooks/template_redirect/). This will parse the page and read all images from the page. For each image, it will check if the disk contains a WebP or AVIF on the same location. If any, it will create a picture element and add the WebP/AVIF sources as a source attribute.class-tiny-compress.php:195
. This would cause warnings in the customers' UI. This went unnoticed because we previously uploaded files and didn't need the ID of the recently uploaded file.Screenshots
The settings screen will show the options for conversion.
The media library list view ill show compression and conversions. Conversions are hidden if the conversion setting is disabled
Show image statistics for conversion..
Image statistics when conversion is disabled.
The image source is replaced by a picture element with the sources as attribute
Further Improvements
Below are further improvements we can make on this feature. Discussion is open to see if these are all could haves or if some of them are must haves.