Skip to content

Commit

Permalink
Added lazy loading attribute to thumbnail image tags to lazily load i…
Browse files Browse the repository at this point in the history
…mages outside viewport.
  • Loading branch information
m3tal10 committed Nov 16, 2024
1 parent 53bd504 commit c7ab0e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<template>

<span class="channel-thumbnail">
<!--
we consider thumbnails decorative - empty `alt`
Expand All @@ -10,14 +9,12 @@
class="image"
:src="thumbnailUrl"
alt=""
>
loading="lazy"
/>
</span>

</template>


<script>
export default {
name: 'ChannelThumbnail',
props: {
Expand All @@ -28,12 +25,9 @@
},
},
};
</script>


<style lang="scss" scoped>
.channel-thumbnail {
display: flex;
flex-direction: column;
Expand All @@ -49,5 +43,4 @@
height: auto;
max-height: 100%;
}
</style>
11 changes: 2 additions & 9 deletions kolibri/plugins/learn/assets/src/views/thumbnails/Thumbnail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<template>

<span
class="thumbnail"
:style="thumbnailStyles"
Expand All @@ -17,15 +16,13 @@
class="image"
:src="thumbnailUrl"
alt=""
>
loading="lazy"
/>
<slot name="labels"></slot>
</span>

</template>


<script>
/**
* Displays a thumbnail in 16:9 ratio. A thumbnail image with
* a different aspect ratio will be letterboxed to fit 16:9.
Expand Down Expand Up @@ -61,12 +58,9 @@
},
},
};
</script>


<style lang="scss" scoped>
/*
16:9 aspect ratio with letterboxing (9 / 16 = 0.5625 = 56.25%)
https://www.sitepoint.com/maintain-image-aspect-ratios-responsive-web-design/
Expand Down Expand Up @@ -105,5 +99,4 @@
opacity: 0.3;
}
}
</style>

0 comments on commit c7ab0e7

Please sign in to comment.