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
Use <picture> for g-image #212
Comments
We can also let <g-image :thumb="miniUrl" :src="url" :srcset="srcSet" :width="width" sizes="..." /> |
It would be great if we could use g-image with external images. It sounds like a cool feature:) |
Hi @hjvedvik |
@hjvedvik, Here is the lazy loading script recommended by Google in their Google Dev Image Optimization post : lazysizes I don't know if it's this one you use but it looks very interesting and flexible. +1 @arifhussain353, it could be useful to separate optimizations. Default Add-on options could be:
|
Hi, Here are 2 very interesting loaders that could be used as a starting point to implement new placeholder's techniques. I think these are maybe the 2 best techniques available now. |
Have you ever thought about use With |
@derevandal You're right. I think we should use |
Keep in mind that the |
An idea here could be to allow for Smooth fade-in of the image would be great, but as a 2nd to allowing for As an aside I'm using |
At the moment is there any hack that we could fade in from the blurred image to the full image? I already looked to the vue-lazy-image and it works but g-image is nice cause it generates other image sizes. As a hack maybe with some JS that detects the change of the src and activates a CSS class with blur property and a transition time? EDIT: Turns out that Gridsome is awesome and already have a |
@Kulcanhez could you share your solution please? The simplest solution I came up with was that kind of thing. // (SASS style)
.g-image-container
overflow: hidden
.g-image--lazy
transition: filter .8s ease-out
.g-image--loading
filter: blur(10px)
.g-image--loaded
filter: none But it's not perfect. It's just applying another blur to the image, and requires a container if you don't want the blurred borders. It would be ideal to fade out the loaded image on top of the blurred one (which means 2 |
Eheh, of course, I can share ❤️ This one was a funny one to find a workaround, but from my side is working nicely.
Let me know if there's any improvement to make. Happy to help 😄 |
Hey @Kulcanhez, thanks for sharing :) I'm still not very satisfied with it, and the best improvement to me is something like @tomtev suggested, with 2 HTML elements, one for the blurred image and 1 for the loaded image ...at least during the transition. |
@philoozushi I think we might end up with markup that looks something like this: <figure class="g-image">
<div class="g-image--blur">
<img class="g-image--fallback" src="">
</div>
<img class="g-image--image" src="">
<noscript>...</noscript>
<slot />
</figure> That will allow Gridsome to show a nicer looking blurred image + fade in the original image once it's loaded. |
Seems good to me. Do you think it will come in the 0.8? 😁 |
@philoozushi after some testing I noticed that both of our codes are really slow on Firefox for Android and for Mac. There are a lot of issues that you can find on Google but I haven't the solution for our case. For now, I'll remove the transition. Let me know if you have any ideas. |
Summary
Now the
<g-image>
creates a small blurred<img>
element before it changes into the lazy loaded image. It just replaces the image, so there is no smooth transition.A
<figure>
element makes a wrapper around the image, so it's easy to, for example, fade in the image once loaded. We can also add a link to the image inside the<figure>
.Benefits:
Basic example
With a link to the original / large image: (Can be used for lightboxes)
Learn more about the figure element:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure
The text was updated successfully, but these errors were encountered: