Closed deveth0 closed 7 years ago
Hiya! This plugin aims to be implementation agnostic, but the feature you're suggesting would couple it to the sizes
attribute. For this reason, I'm not going to add the feature.
What you could do, though, is store your sizes in the Jekyll config and then use them to build the sizes
attribute in your responsive image template.
thanks for your fast feedback. that's what I currently do but I thought it might be easier as suggested above. But yeah, you're right, this would be a different approach to the problem not really compatible with your (great!!) plugin.
For whom it may concern: I implemented a simple "extension" which can be used with @wildlyinaccurate ' s plugin:
You have to append this snipped at the end of your img or picture-tag in the template:
{% assign rendition= site.media_renditions.[media_rendition] %}
{% if rendition != nil %}
sizes="{{ rendition.sizes | join: ', '}}"
{%endif%}
Then you can pass a media_rendition to the image(block)
{% responsive_image_block %}
path: {{ include.image }}
media_rendition: tile_2col
{% endresponsive_image_block %}
Those renditions are configure in your _config.yml:
media_renditions:
tile_2col:
sizes:
- "(min-width: 1024px) 960px"
- "(max-width: 1023px) and (min-width: 768px) 1024px"
- "(max-width: 767px) and (min-width: 480px) 768px"
- "(max-width: 479px) 480px"
Full example for responsive-image.html template:
<img alt="{{ alt }}" src="/{{ original.path }}" title="{{ title }}" srcset="{% for i in resized %}/{{ i.path }} {{ i.width }}w,{% endfor %}/{{ original.path }} {{ original.width }}w"
{% assign rendition= site.media_renditions.[media_rendition] %}
{% if rendition != nil %}
sizes="{{ rendition.sizes | join: ', '}}"
{%endif%}
>
Nice, @deveth0!
Hi,
currently you can configure the sizes of images that are generated upon building. Those sizes are used to create the srcset tag. I think it would be helpful, if there is a possibility to configure the "sizes" tag (good introduction) here too.
I imaging something like:
Output could be: