Skip to content

Commit

Permalink
feat: handle image formats other than webp
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed May 24, 2024
1 parent d8f7c23 commit 1096364
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<figcaption>No process image:</figcaption>
<NuxtPicture :modifiers="{ noProcess: true }" src="opera.webp" />
</figure>

<figure>
<figcaption>Avif format:</figcaption>
<NuxtPicture format="avif" src="rhino.jpg" />
</figure>
</div>
</template>

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function getImage(
// process modifiers
const operationsString = operations.join('-')

if (format === 'webp' && !src.endsWith('.webp')) {
src += '.webp'
if (format && !src.endsWith('.' + format)) {
src += '.' + format
}

const getUrl = function (): string {
Expand Down

0 comments on commit 1096364

Please # to comment.