139 |
140 | {#if srcsetavif}
141 |
146 | {/if}
147 | {#if srcsetwebp}
148 |
153 | {/if}
154 |
(imgError = true)}
164 | />
165 |
166 | {#if !immediate && !hidePlaceholder}
167 | {#if placeholdersrc}
168 |
169 | {#if placeholderavif}
170 |
171 | {/if}
172 | {#if placeholderwebp}
173 |
174 | {/if}
175 |
178 |
179 | {:else}
180 |

190 | {/if}
191 | {/if}
192 |
193 |
194 |
223 |
--------------------------------------------------------------------------------
/src/Image.ts:
--------------------------------------------------------------------------------
1 | import { SvelteComponent } from 'svelte';
2 |
3 | export interface ImageProps {
4 | /**
5 | * Image url
6 | */
7 | src: string;
8 |
9 | /**
10 | * Alternate text for the image
11 | */
12 | alt?: string;
13 |
14 | /**
15 | * CSS classes to apply to image
16 | */
17 | class?: string;
18 |
19 | /**
20 | * Resize image to specified width in pixels
21 | */
22 | width?: number | string;
23 |
24 | /**
25 | * Set to true to disable lazy-loading
26 | *
27 | * @default false
28 | */
29 | immediate?: boolean;
30 |
31 | /**
32 | * Amount of blur to apply to placeholder
33 | *
34 | * @default 40
35 | */
36 | blur?: number | string;
37 |
38 | /**
39 | * Quality of the resized images
40 | *
41 | * @default sharp's default quality
42 | */
43 | quality?: number | string;
44 | }
45 |
46 | /**
47 | * Image lazy loading Svelte component
48 | * for the svimg package
49 | */
50 | export default class Image extends SvelteComponent