Hi @alexlopezleon ,
Thanks for reaching out and for the detailed breakdown of your issue — we really appreciate it.
What you’re experiencing with the duplicated ?auto=format,compress parameters in media linkswhen using a Link field inside a Group is a known issue that’s been observed by multiple developers in the Prismic community. This typically occurs when a Link field is used to “Link to Media”, particularly for images, and can result in malformed URLs when rendered using .url or prismic.asLink().
It’s been reported and discussed on the Prismic community forum here:
At the moment, the recommended workaround is to:
- Use prismic.asImageSrc(linkField, { auto: ['format'] }) only if you’re sure the link is to an image.
- For mixed media (image or external video), access .url directly and sanitize it, for example:
const rawUrl = project?.data?.featured_media?.[0]?.main_media?.url ?? '';
const cleanedUrl = rawUrl.replace(/\?auto=[^?]+(\?auto=[^?]+)?/, '?auto=format');
We understand how this can be frustrating, and if you’re encountering this issue in production, we recommend adding a short validation or cleaning step like the above to ensure correct rendering.
Let us know if you’d like help writing a utility function to handle this automatically in your project.