Skip to content

How to use the $img utility with script setup in Nuxt? #811

Discussion options

You must be logged in to vote

To answer my own question. I was reading the old docs (for Nuxt 2). These are the correct once: https://v1.image.nuxtjs.org/api/dollarimg

This works:

const $img = useImage()
const myImgUrl = $img(
  myFileName,
  {
    width: 100,
  },
  { provider: 'cloudinary' },
)
console.log(myImgUrl)

However, myImgUrl seems to be of type any.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by leopoldkristjansson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant