-
Notifications
You must be signed in to change notification settings - Fork 162
Feature: CSS Gradient Low Quality Image Placeholders #2550
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
nickchomey
wants to merge
22
commits into
WordPress:trunk
Choose a base branch
from
nickchomey:feature/css-gradient-lqip
base: trunk
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
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
63249d6
allow falling back to original image if no subsizes available
nickchomey 61ac59b
always override core image editor classes, such that same editor is u…
nickchomey b9d1b22
remove redundant fn call
nickchomey 388929f
abstract the get metadata functions
nickchomey 2aff2ab
Remove unnecessary wp_maybe_generate_attachment_metadata calls. They …
nickchomey 2cc5c2a
use create rather than create_upload_object, which prevents calling d…
nickchomey 8f60d84
require the editor classes, just in case (seems to be missing when th…
nickchomey 66d3dcb
implement GD tests
nickchomey 06f59af
return raw rgb rather than hex. This will facilitate the lqip gradien…
nickchomey 0f5cf74
fix linting
nickchomey 8aac22f
Implement Blurhash-like CSS Gradient approach for LQIP
nickchomey 7be8cae
average pixels in linear light - fix #2535
nickchomey ee8f084
fix formatting and linting
nickchomey d69edca
fix plugin check
nickchomey 893feee
address code review comments
nickchomey 092ff88
revert change due to phpstan failure
nickchomey 38813b0
remove testing hover css
nickchomey 6636887
Add build config to minify lqip.css for dominant-color-images
westonruter 1a5c83e
Add newline at EOF
westonruter bd3e6a4
fixes
nickchomey 816df46
address looping all pixels
nickchomey ea86570
fix format
nickchomey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| /** | ||
| * CSS-only Low Quality Image Placeholder (LQIP) | ||
| * | ||
| * Elements with an inline --lqip custom property (e.g. style="--lqip:192900") | ||
| * automatically receive a multi-cell gradient background derived from the image's | ||
| * six dominant color regions. The image itself sits on top once loaded, hiding | ||
| * the placeholder. | ||
| * | ||
| * Ported from https://github.com/Kalabasa/leanrada.com/blob/bca158ebdc8488364ecac923413ca40b2326826d/main/site/common.css#L140-L337 | ||
| */ | ||
|
|
||
| @property --lqip { | ||
| syntax: "<number>"; | ||
| inherits: true; | ||
| initial-value: 0; | ||
| } | ||
|
|
||
| [style*="--lqip:"] { | ||
| --lqip-ca: mod(round(down, calc((var(--lqip) + 524288) / 262144)), 4); | ||
| --lqip-cb: mod(round(down, calc((var(--lqip) + 524288) / 65536)), 4); | ||
| --lqip-cc: mod(round(down, calc((var(--lqip) + 524288) / 16384)), 4); | ||
| --lqip-cd: mod(round(down, calc((var(--lqip) + 524288) / 4096)), 4); | ||
| --lqip-ce: mod(round(down, calc((var(--lqip) + 524288) / 1024)), 4); | ||
| --lqip-cf: mod(round(down, calc((var(--lqip) + 524288) / 256)), 4); | ||
| --lqip-ll: mod(round(down, calc((var(--lqip) + 524288) / 64)), 4); | ||
| --lqip-aaa: mod(round(down, calc((var(--lqip) + 524288) / 8)), 8); | ||
| --lqip-bbb: mod(calc(var(--lqip) + 524288), 8); | ||
|
|
||
| --lqip-ca-clr: hsl(0 0% calc(var(--lqip-ca) / 3 * 100%)); | ||
| --lqip-cb-clr: hsl(0 0% calc(var(--lqip-cb) / 3 * 100%)); | ||
| --lqip-cc-clr: hsl(0 0% calc(var(--lqip-cc) / 3 * 100%)); | ||
| --lqip-cd-clr: hsl(0 0% calc(var(--lqip-cd) / 3 * 100%)); | ||
| --lqip-ce-clr: hsl(0 0% calc(var(--lqip-ce) / 3 * 100%)); | ||
| --lqip-cf-clr: hsl(0 0% calc(var(--lqip-cf) / 3 * 100%)); | ||
| --lqip-base-clr: oklab( | ||
| calc(var(--lqip-ll) / 3 * 0.6 + 0.2) | ||
| calc(var(--lqip-aaa) / 8 * 0.7 - 0.35) | ||
| calc((var(--lqip-bbb) + 1) / 8 * 0.7 - 0.35) | ||
| ); | ||
|
|
||
| --lqip-stop10: 2%; | ||
| --lqip-stop20: 8%; | ||
| --lqip-stop30: 18%; | ||
| --lqip-stop40: 32%; | ||
| background-blend-mode: | ||
| hard-light, hard-light, hard-light, hard-light, hard-light, hard-light, | ||
| overlay, overlay, overlay, overlay, overlay, overlay, | ||
| normal; | ||
| background-image: radial-gradient(50% 75% at 16.67% 25%, | ||
| rgb(from var(--lqip-ca-clr) r g b / 50%), | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 83.33% 25%, | ||
| rgb(from var(--lqip-cc-clr) r g b / 50%), | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 50% 25%, | ||
| rgb(from var(--lqip-cb-clr) r g b / 50%), | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 16.67% 75%, | ||
| rgb(from var(--lqip-cd-clr) r g b / 50%), | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 83.33% 75%, | ||
| rgb(from var(--lqip-cf-clr) r g b / 50%), | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 50% 75%, | ||
| rgb(from var(--lqip-ce-clr) r g b / 50%), | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(50% - var(--lqip-stop10) / 2)) 10%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(50% - var(--lqip-stop20) / 2)) 20%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(50% - var(--lqip-stop30) / 2)) 30%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(50% - var(--lqip-stop40) / 2)) 40%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop40) / 2)) 60%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop30) / 2)) 70%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop20) / 2)) 80%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop10) / 2)) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 16.67% 25%, | ||
| var(--lqip-ca-clr), | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-ca-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 50% 25%, | ||
| var(--lqip-cb-clr), | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-cb-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 83.33% 25%, | ||
| var(--lqip-cc-clr), | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-cc-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 16.67% 75%, | ||
| var(--lqip-cd-clr), | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-cd-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 50% 75%, | ||
| var(--lqip-ce-clr), | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-ce-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| radial-gradient(50% 75% at 83.33% 75%, | ||
| var(--lqip-cf-clr), | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(100% - var(--lqip-stop10))) 10%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(100% - var(--lqip-stop20))) 20%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(100% - var(--lqip-stop30))) 30%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(100% - var(--lqip-stop40))) 40%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop40))) 60%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop30))) 70%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop20))) 80%, | ||
| rgb(from var(--lqip-cf-clr) r g b / calc(var(--lqip-stop10))) 90%, | ||
| transparent), | ||
| linear-gradient(0deg, var(--lqip-base-clr), var(--lqip-base-clr)); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PhpStorm's static analysis is flagging these:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added a property. let me know if that doesnt fix the static analysis problem