-
Notifications
You must be signed in to change notification settings - Fork 104
Estimate the thumbnail image sizes #3881
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
base: develop
Are you sure you want to change the base?
Conversation
Kudos, SonarCloud Quality Gate passed!
|
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!
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3881 +/- ##
=============================================
+ Coverage 31.46% 31.48% +0.01%
- Complexity 5008 5010 +2
=============================================
Files 298 298
Lines 22014 22023 +9
=============================================
+ Hits 6926 6933 +7
- Misses 15088 15090 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
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?