Hi,
I’m currently trying to create Nuxt static site using Prismic.
I would like to cache/download the Prismic image when I run npm run generate as to prevent trafic from counting againt my CDN quota. This is possible with NuxtImage and the ipx provider by doing like so.
Here is my nuxt.config.ts
image: {
provider: 'ipx',
domains: ['static.swapcard.com', 'images.prismic.io', 'interface-qc.cdn.prismic.io'],
quality: 70,
format: ['webp'],
},
And how NuxtImage is used inside my component:
<NuxtImg :src="speaker.img.url" :alt="speaker.img.alt" width="322" height="375" />
So this original URL: src="https://images.prismic.io/interface-qc/Z9jSKjiBA97GikvL_profile_picture-1-.png?auto=format,compress&rect=27,0,322,375&w=322&h=375&q=70"
Will tranformed and cached to this:
src="/_ipx/q_70&s_322x375/https:/images.prismic.io/interface-qc/Z9jSKjiBA97GikvL_profile_picture-1-.png%3Fauto=format,compress%26rect=27,0,322,375%26w=322%26h=375"
The problem is that ipx doesn't like that there are params inside the prismic URL, and this will crash the static site generator.
These params are not needed, because nuxt will do it's own resizing and convertion.
So my question is, is there a way to retreive the original URL, without the query params (?auto=format,compress&rect=27,0,322,375&w=322&h=375&q=70) ?
The API response for the image field is like so and only provide the transformed url, not the original image url.
{
"dimensions": { "width": 322, "height": 375 },
"alt": null,
"copyright": null,
"url": "https://images.prismic.io/interface-qc/Z9jSKjiBA97GikvL_profile_picture-1-.png?auto=format, compress&rect=27,0,322,375&w=322&h=375",
"id": "Z9jSKjiBA97GikvL",
"edit": { "x": 27, "y": 0, "zoom": 1, "background": "transparent" }
}
My current and ugly workaroud is to replace :src="speaker.img.url" for :src="speaker.img.url.split('?')[0]" .
This means that Nuxt image receive src="https://images.prismic.io/interface-qc/Z9jSKjiBA97GikvL_profile_picture-1-.png" and genrate src="/_ipx/q_70&s_322x375/https:/images.prismic.io/interface-qc/Z9jSKjiBA97GikvL_profile_picture-1-.png" instead