zerodevx / svelte-img

High-performance responsive/progressive images for SvelteKit

Home Page:https://zerodevx.github.io/svelte-img/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to customise sizes, width/height, and other prop?

Oceanbao opened this issue · comments

Bravo and thank you for making this tool. I find it the best among a handful image-optimisation libs for Svelte that I Googled.

I was wondering is there a way to set the sizes prop on the resulting <img> tag? Also the width/heigth and media props on <source> tag.

Thank you so much.

Hey, glad you found this useful.

I was wondering is there a way to set the sizes prop on the resulting <img> tag?

You can just set sizes prop (or in fact any other standard <img> tag props) on the <Img> component and they will be mirrored into the resulting <img> tag.

Also the width/heigth and media props on <source> tag

Not right now at the moment - this package is intended to be kind of a set-and-forget thing to replace how one would normally use an <img> tag, so I thought art direction may be out of scope. Might add support in a future release!

That's superb. Thank you for clearing that up. That is very useful to know.