Load different images sizes depending on the screen size
Use responsive images `<picture>` to load different sizes
This commit is contained in:
@@ -55,17 +55,17 @@
|
||||
<div class="gallery">
|
||||
<div class="gallery__images">
|
||||
{#each photos as photo, index}
|
||||
<div class="gallery__images--photo"
|
||||
<picture class="gallery__images--photo"
|
||||
class:prev={index === 0}
|
||||
class:active={index === 1}
|
||||
class:next={index === 2}
|
||||
>
|
||||
<img
|
||||
src="{fn.getThumbnail(photo.image.private_hash, 800)}"
|
||||
srcset="{fn.getThumbnail(photo.image.private_hash, 1200)} 1200w, {fn.getThumbnail(photo.image.private_hash, 1600)} 1600w"
|
||||
alt="{photo.name}, {photo.location.name}, {photo.location.country.name}"
|
||||
/>
|
||||
</div>
|
||||
<source media="(min-width: 968px)" srcset={fn.getThumbnail(photo.image.private_hash, 1400)}>
|
||||
<source media="(min-width: 800px)" srcset={fn.getThumbnail(photo.image.private_hash, 900)}>
|
||||
<source media="(min-width: 500px)" srcset={fn.getThumbnail(photo.image.private_hash, 600)}>
|
||||
<source media="(min-width: 300px)" srcset={fn.getThumbnail(photo.image.private_hash, 400)}>
|
||||
<img src="{fn.getThumbnail(photo.image.private_hash, 900)}" alt="{photo.name}, {photo.location.name}, {photo.location.country.name}">
|
||||
</picture>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user