File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ <template >
2+ <img
3+ :data-srcset =" srcset"
4+ :data-aspectratio =" aspectRatio"
5+ :data-parent-fit =" parentFit"
6+ :alt =" alt"
7+ class =" lazyload"
8+ sizes =" auto"
9+ >
10+ </template >
11+
12+ <script setup lang="ts">
13+ interface Props {
14+ src: string
15+ alt: string
16+ sizes? : string
17+ loading? : string
18+ aspectRatio? : string | boolean
19+ parentFit? : string | boolean
20+ }
21+
22+ const props = withDefaults (defineProps <Props >(), {
23+ sizes: ' 100vw' ,
24+ loading: ' lazy' ,
25+ aspectRatio: false ,
26+ parentFit: false ,
27+ })
28+
29+ const srcset = computed <string >(() => {
30+ const img = useImage ()
31+ return img .getSizes (props .src , {
32+ sizes:
33+ ' xs:100vw sm:100vw md:100vw lg:100vw xl:100vw xxl:100vw xxxl:100vw xxxxl:100vw xxxxxl:100vw' ,
34+ modifiers: {
35+ format: ' webp' ,
36+ quality: 60 ,
37+ },
38+ }).srcset
39+ })
40+ </script >
You can’t perform that action at this time.
0 commit comments