Introduce placeholder support in MediaLibrary using Blurhash #3326
jessedobbelaere
started this conversation in
Ideas / Feature Requests
Replies: 1 comment
-
I would do this as a PR to the restructure core branch (Fork 6), The minimum PHP version is already higher than 7.3 there anyway. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
💭 Why
Loading images often is very cumbersome on slower connections. The layout jumps a lot too while loading if you don't set the width/height. If the LiipImagineBundle thumbnail cache is not warmed up, the thumbnails also have to generated first, taking some extra response time in addition to loading the images... Your beautiful page can be full of empty boxes because all the images have not loaded yet.
❓ What is Blurhash
Blurhash is an algorithm written by Dag Ågren for Wolt (woltapp/blurhash) that encodes an image into a short (~20-30 byte) ASCII string. When you decode the string back into an image, you get a gradient of colors that represent the original image. This can be useful for scenarios where you want an image placeholder before loading, or even to censor the contents of an image.
Images can be huge, they leave your customers waiting and images loading in can move around the page layout. With a placeholder image this issue no longer exists and with a blurred image you give your users something engaging while they wait.
Before:
After:
✨ Fork CMS implementation
Blurhash has implementations for most languages. The way I currently see it implemented is:
LEHV9uae2yk8pyo0adR*.7kCMdnj
in theMediaItem
table as metadata of the image.The frontend can then retrieve the blurhash string as part of the MediaItem object in Twig. There are tons of options to render it:
blurhash-to-css
frontend lib that turns the blurhash string into a CSS background using gradients (https://www.bram.us/2021/03/07/convert-blurhash-to-a-css-background-with-blurhash-to-css/)Other media libs that implemented blurhash:
blur_hash
onMediaItem
= Breaking changemodule_settings
?Beta Was this translation helpful? Give feedback.
All reactions