Skip to content

Commit 1e4e147

Browse files
committed
Switch to uing <picture> for responsive images
1 parent d574787 commit 1e4e147

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ jekyll-diagrams:
232232
# configuration, see https://github.com/zhustec/jekyll-diagrams.
233233
# feel free to comment out this section if not using jekyll diagrams.
234234

235+
235236
# -----------------------------------------------------------------------------
236237
# Optional Features
237238
# -----------------------------------------------------------------------------
@@ -249,6 +250,7 @@ enable_project_categories: true # enables categorization of projects into
249250
# multiple categories
250251
enable_medium_zoom: true # enables image zoom feature (as on medium.com)
251252

253+
252254
# -----------------------------------------------------------------------------
253255
# Library versions
254256
# -----------------------------------------------------------------------------

_includes/responsive_img.html

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
{% assign largest = resized | sort: 'width' | last %}
2-
{% capture srcset %}
3-
{% for i in resized %}
4-
{{ i.path | relative_url }} {{ i.width }}w,
5-
{% endfor %}
6-
{% endcapture %}
7-
8-
<img {% if class %}class="{{ class }}"{% endif %} src="{{ largest.path | relative_url }}" srcset="{{ srcset | strip_newlines }} {{ path | relative_url }} {{ original.width }}w" {% if alt %}alt="{{ alt }}"{% endif %} {% if title %}title="{{ title }}"{% endif %} {% if zoomable %}data-zoomable{% endif %}/>
1+
<picture>
2+
{% for i in resized %}
3+
<source media="(max-width: {{ i.width }}px)" srcset="{{ i.path | relative_url }}">
4+
{% endfor %}
5+
<img {% if class %}class="{{ class }}"{% endif %} src="{{ path | relative_url }}" {% if alt %}alt="{{ alt }}"{% endif %} {% if title %}title="{{ title }}"{% endif %} {% if zoomable %}data-zoomable{% endif %} />
6+
</picture>

0 commit comments

Comments
 (0)