image icon indicating copy to clipboard operation
image copied to clipboard

Incorrect preload links for single size, multiple densities images

Open raggesilver opened this issue 7 months ago • 0 comments

The following scenario does not work properly:

<template>
  <NuxtImg
    src="/my-img.webp"
    width="300"
    height="300"
    fit="inside"
    preload
  />
</template>

This generates something like:

<link rel="preload" as="image" href="/_ipx/f_webp&fit_inside&s_300x300/my-img.webp">

But that does not take densities into account (1x and 2x by default).

<link rel="preload" as="image" href="/_ipx/f_webp&fit_inside&s_600x600/my-img.webp" imagesrcset="/_ipx/f_webp&fit_inside&s_300x300/my-img.webp 1x, /_ipx/f_webp&fit_inside&s_600x600/my-img.webp 2x">

raggesilver avatar May 25 '25 02:05 raggesilver