Created
July 29, 2016 23:37
-
-
Save dangayle/9605e167f8396210de27a6000f2982cf to your computer and use it in GitHub Desktop.
Using lazysizes in Django
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
{% load static mogrify %} | |
<img | |
class="lazyload {{ class }}" | |
src="{% static 'sv3/img/spokesman-logo.png' %}" | |
data-sizes="auto" | |
data-srcset=" | |
{% mogrify img_url resize '300x169' %} 300w, | |
{% mogrify img_url resize '530x298' %} 530w, | |
{% mogrify img_url resize '720x408' %} 720w, | |
{% mogrify img_url resize '1170x658' %} 1170w," | |
alt="{{ img_alt }}" /> |
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
{% load static mogrify %} | |
<img | |
class="lazyload {{ class }}" | |
src="{% static 'sv3/img/spokesman-logo.png' %}" | |
data-sizes="auto" | |
data-srcset=" | |
{% mogrify img_url thumbnail '300' %} 300w, | |
{% mogrify img_url thumbnail '530' %} 530w, | |
{% mogrify img_url thumbnail '720' %} 720w, | |
{% mogrify img_url thumbnail '1170' %} 1170w," | |
alt="{{ img_alt }}" /> |
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
<figure> | |
<a href="{{ story.get_absolute_url }}"> | |
{% include 'sv3/media/srcset_resize.html' with img_url=story.primary_photo.photo.url img_alt=story.primary_photo.get_pretty_caption|force_escape %} | |
<figcaption>{{ story.primary_photo.get_pretty_caption|safe }}</figcaption> | |
</a> | |
</figure> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment