-
Notifications
You must be signed in to change notification settings - Fork 102
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
Estimate the thumbnail image sizes #3881
base: develop
Are you sure you want to change the base?
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Presuming it's a one-off task on upload, could you actually do the resize, capture the bytesize, and then dump the thumbnail image? |
We generate attachment metadata "on the fly". One big benefit to this is that thumbnails don't need to be "regenerated" when new sizes are added by plugins/themes. Actually resizing and capturing the bitesize for every attachment thumbnail size on every image could take a very large amount of time on many of our sites 🙃 |
deded3c
to
b235946
Compare
This pull request has been marked stale because it has been open for 60 days with no activity. If there is no activity within 7 days, it will be closed. This is an automation to keep pull requests manageable and actionable and is not a comment on the quality of this pull request nor on the work done so far. Closed PRs are still valuable to the project and their branches are preserved. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov Report
@@ Coverage Diff @@
## develop #3881 +/- ##
=============================================
+ Coverage 32.29% 32.31% +0.02%
- Complexity 3794 3796 +2
=============================================
Files 231 231
Lines 16987 16996 +9
=============================================
+ Hits 5486 5493 +7
- Misses 11501 11503 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Description
In WP 6.0, the
filesize
for attachment thumbnails was added to the attachment metadata. We added support for this here: #2991Since we don't actually generate attachments, the filesize was just set to that of the original image. This has some unfortunate implications wherein a sized-down image will be seen as too large for certain tasks (like social media usage, seen here in yoast seo).
As a workaround to this, it was proposed that we can instead just estimate what the resized image will be. So this is what I attempted in this PR.
Problems
It's not very consistent >.<.
JPG Image
The estimates by the current logic in this PR (pretty close):
PNG Image
The estimates by the current logic in this PR (off by half):
So as you can see, we could divide our current estimate by 2 and be pretty close for the PNG. But JPG would then be further off. This doesn't really account for webp conversions either (which I think is fine since those change based on browser support, though maybe we need to account for it if a webp image is uploaded as the original).
So what should we do? Alter the formula based on image type? Am I missing something?