Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
width="300"
height="200"
class="rounded"
alt="Mountain landscape by Benjamin Voros"
/>
<figcaption class="text-gray-600 text-xs mt-3">
Photo by <a
Expand All @@ -28,6 +29,7 @@
width="3750"
height="2500"
sizes="xs:200px md:500px lg:1024"
alt="Mountain landscape by Kurt Cotoaga"
/>
<figcaption class="text-gray-600 text-xs mt-3">
Photo by <a
Expand Down
6 changes: 6 additions & 0 deletions playground/app/pages/events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
src="/images/colors.jpg"
width="500"
height="500"
alt=""
@load="() => { console.log('Image was loaded') }"
/>
<nuxt-picture
src="/images/colors.jpg"
width="500"
height="500"
alt=""
@load="() => { console.log('Image was loaded') }"
/>

Expand All @@ -20,13 +22,15 @@
placeholder
width="500"
height="500"
alt=""
@load="() => { console.log('Image was loaded') }"
/>
<nuxt-picture
:src="src"
placeholder
width="500"
height="500"
alt=""
@load="() => { console.log('Image was loaded') }"
/>

Expand All @@ -35,12 +39,14 @@
:src="'nonexistent' + src"
width="500"
height="500"
alt=""
@error="() => { console.log('Error loading image') }"
/>
<nuxt-picture
:src="'nonexistent' + src"
width="500"
height="500"
alt=""
@error="() => { console.log('Error loading image') }"
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions playground/app/pages/img.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
src="/images/colors.jpg"
width="500"
height="500"
alt=""
@load="isLoaded = true"
/>
<p>Received onLoad event: {{ isLoaded }}</p>
Expand All @@ -15,6 +16,7 @@
placeholder
width="500"
height="500"
alt=""
@load="isLoaded = true"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions playground/app/pages/ipx-layers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
src="/images/colors.jpg"
width="500"
height="500"
alt=""
@load="isLoadedRoot = true"
/>
<p>Received onLoad event: {{ isLoadedRoot }}</p>
Expand All @@ -14,6 +15,7 @@
src="/images/colors-layer.jpg"
width="500"
height="500"
alt=""
@load="isLoadedLayer = true"
/>
<p>Received onLoad event: {{ isLoadedLayer }}</p>
Expand All @@ -23,6 +25,7 @@
src="/images/colors-layer-config.jpg"
width="500"
height="500"
alt=""
@load="isLoadedLayerWithConfig = true"
/>
<p>Received onLoad event: {{ isLoadedLayerWithConfig }}</p>
Expand Down
1 change: 1 addition & 0 deletions playground/app/pages/picture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
format="avif,webp"
width="500"
height="500"
alt=""
@load="isLoaded = true"
/>
<p>Received onLoad event: {{ isLoaded }}</p>
Expand Down
1 change: 1 addition & 0 deletions playground/app/pages/provider/[provider].vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:provider="provider.name as any"
v-bind="sample"
:preload="{ fetchPriority: 'auto' }"
alt=""
/>
<pre>{{ sample }}</pre>
</div>
Expand Down
5 changes: 5 additions & 0 deletions playground/app/pages/responsive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
<NuxtImg
:sizes="{ sm: 100, md: 500 }"
src="/images/damavand.jpg"
alt=""
/>

<h2>nuxt-picture</h2>
<NuxtPicture
:sizes="{ sm: 100, md: 500 }"
src="/images/damavand.jpg"
alt=""
/> -->
<div style="width: 50vw">
i'm 50vw
Expand All @@ -18,12 +20,14 @@
src="/logos/nuxt.png"
sizes="sm:100vw md:50vw lg:400px"
loading="lazy"
alt=""
/>
<br>
<nuxt-picture
src="/logos/nuxt.png"
sizes="sm:100vw md:50vw lg:400px"
loading="lazy"
alt=""
/>

<div style="width: 50vw; background-color: red">
Expand All @@ -34,6 +38,7 @@
sizes="sm:100vw md:50vw lg:400px"
placeholder
class="responsive-placeholder-img"
alt=""
/>
</div>
</template>
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/utils/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface BaseImageProps<Provider extends keyof ConfiguredImageProviders>
preload?: boolean | { fetchPriority: 'auto' | 'high' | 'low' }

// <img> attributes
alt: string
width?: string | number
height?: string | number
crossorigin?: 'anonymous' | 'use-credentials' | boolean
Expand All @@ -46,6 +47,7 @@ export const useImageProps = <Provider extends keyof ConfiguredImageProviders>(p
height: parseSize(props.height),
crossorigin: props.crossorigin === true ? 'anonymous' : props.crossorigin || undefined,
nonce: props.nonce,
alt: props.alt,
}))

const imageModifiers = computed(() => {
Expand Down
Loading
Loading