Lazy load all images (#5528)

* changes

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
aliabid94 2023-09-13 10:33:04 -07:00 committed by GitHub
parent c5fe8ebadb
commit dc86e4a7e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,7 @@
---
"@gradio/gallery": minor
"@gradio/image": minor
"gradio": minor
---
feat:Lazy load all images

View File

@ -207,6 +207,7 @@
style="height: calc(100% - {_value[selected_image][1]
? '80px'
: '60px'})"
loading="lazy"
/>
{#if _value[selected_image][1]}
<div class="caption">
@ -229,6 +230,7 @@
src={image[0].data}
title={image[1] || null}
alt={image[1] || null}
loading="lazy"
/>
</button>
{/each}
@ -265,6 +267,7 @@
<img
alt={caption || ""}
src={typeof image === "string" ? image : image.data}
loading="lazy"
/>
{#if caption}
<div class="caption-label">

View File

@ -224,6 +224,7 @@
class:scale-x-[-1]={source === "webcam" && mirror_webcam}
class:selectable
on:click={handle_click}
loading="lazy"
/>
{:else if (tool === "sketch" || tool === "color-sketch") && (value !== null || static_image)}
{#key static_image}
@ -234,6 +235,7 @@
alt=""
on:load={handle_image_load}
class:webcam={source === "webcam" && mirror_webcam}
loading="lazy"
/>
{/key}
{#if img_width > 0}
@ -279,6 +281,7 @@
class:webcam={source === "webcam" && mirror_webcam}
class:selectable
on:click={handle_click}
loading="lazy"
/>
{/if}
</Upload>
@ -341,6 +344,7 @@
class:selectable
class:webcam={source === "webcam" && mirror_webcam}
on:click={handle_click}
loading="lazy"
/>
{:else if (tool === "sketch" || tool === "color-sketch") && (value !== null || static_image)}
{#key static_image}
@ -351,6 +355,7 @@
alt=""
on:load={handle_image_load}
class:webcam={source === "webcam" && mirror_webcam}
loading="lazy"
/>
{/key}
{#if img_width > 0}
@ -393,6 +398,7 @@
class:webcam={source === "webcam" && mirror_webcam}
class:selectable
on:click={handle_click}
loading="lazy"
/>
{/if}
</div>

View File

@ -61,7 +61,13 @@
<!-- TODO: fix -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-noninteractive-element-interactions-->
<img src={value} alt="" class:selectable on:click={handle_click} />
<img
src={value}
alt=""
class:selectable
on:click={handle_click}
loading="lazy"
/>
{/if}
<style>