-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move sample templates into sample-templates/ directory; update README
- Loading branch information
1 parent
d902ec7
commit 3cf3bc7
Showing
5 changed files
with
177 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% comment %} | ||
Render your responsive images using Imager.js (https://github.com/BBC-News/Imager.js/), with the smallest resized image used as a fallback. | ||
|
||
Usage: | ||
|
||
{% responsive_image path: assets/image.jpg alt: "A description of the image" %} | ||
|
||
(P.S. You can safely delete this comment block) | ||
{% endcomment %} | ||
|
||
{% assign smallest = resized | sort: 'width' | first %} | ||
|
||
<div class="responsive-image"> | ||
<img class="responsive-image__placeholder" src="/{{ smallest.path }}"> | ||
<div class="responsive-image__delayed" data-src="/assets/resized/{width}/{{ original.basename }}"></div> | ||
</div> | ||
|
||
<script> | ||
new Imager('.responsive-image__delayed', { | ||
availableWidths: [{{ resized | map: 'width' | join: ', ' }}] | ||
onImagesReplaced: function() { | ||
$('.responsive-image__placeholder').hide(); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% comment %} | ||
Render your responsive images using <picture>, with the original asset used as a fallback. Note: If your original assets are not web-friendly (e.g. they are very large), you can use a resized image as the fallback instead. See the srcset-resized-fallback.html template for how to do this. | ||
|
||
Usage: | ||
|
||
{% responsive_image path: assets/image.jpg alt: "A description of the image" %} | ||
|
||
(P.S. You can safely delete this comment block) | ||
{% endcomment %} | ||
|
||
<picture> | ||
{% for i in resized %} | ||
<source media="(min-width: {{ i.width }}px)" srcset="/{{ i.path }}"> | ||
{% endfor %} | ||
<img src="/{{ path }}"> | ||
</picture> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% comment %} | ||
Render your responsive images using <img srcset>, with the largest resized image used as a fallback. | ||
|
||
Usage: | ||
|
||
{% responsive_image path: assets/image.jpg alt: "A description of the image" %} | ||
|
||
(P.S. You can safely delete this comment block) | ||
{% endcomment %} | ||
|
||
{% assign largest = resized | sort: 'width' | last %} | ||
{% capture srcset %} | ||
{% for i in resized %} | ||
/{{ i.path }} {{ i.width }}w, | ||
{% endfor %} | ||
{% endcapture %} | ||
|
||
<img src="/{{ largest.path }}" alt="{{ alt }}" srcset="{{ srcset | strip_newlines }}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% comment %} | ||
Render your responsive images using <img srcset>, with the original asset used as a fallback. Note: If your original assets are not web-friendly (e.g. they are very large), you might prefer to use the srcset-resized-fallback.html template. | ||
|
||
Usage: | ||
|
||
{% responsive_image path: assets/image.jpg alt: "A description of the image" %} | ||
|
||
(P.S. You can safely delete this comment block) | ||
{% endcomment %} | ||
|
||
{% capture srcset %} | ||
{% for i in resized %} | ||
/{{ i.path }} {{ i.width }}w, | ||
{% endfor %} | ||
{% endcapture %} | ||
|
||
<img src="/{{ path }}" alt="{{ alt }}" srcset="{{ srcset | strip_newlines }}"> |