johannschopplich / unlazy

🪧 Universal lazy loading library for placeholder images leveraging native browser APIs

Home Page:https://unlazy.byjohann.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[vue] No `sizes` attribute set when using `preload="true"`

felixranesberger opened this issue · comments

Reproduction

<UnLazyImage
  :src-set="sourceSet"
  :placeholder-src="placeholderSrc"
  :auto-sizes="true"
  :width="image.width"
  :height="image.height"
  :alt="image.alt"
  :title="image.title"
  :preload="true"
  class="u-object-cover"
/>

Describe the bug

When using :auto-sizes="true" in conjunction with :preload="true" the sizes attribute is not set.

This happens because UnLazyImage.vue checks if props.preload === true and uses the loadImage method to load the image directly. But the loadImage function is not checking, if the sizes attribute should be calculated.

Additional context

No response

Logs

No response

Great catch! Thanks for the thorough bug report. Should be fixed in 6903fe8.

Thanks for the quick fix! 🎉