wildlyinaccurate / jekyll-responsive-image

An unopinionated Jekyll plugin for generating and using responsive images
MIT License
332 stars 48 forks source link

Add ignore_extensions option for vectorial files #107

Closed berarma closed 3 years ago

berarma commented 3 years ago

When using SVG files the plugin is very slow processing them and it would be best to use the original SVG file anyways.

I could avoid using this plugin for vectorial images but then migrating from bitmap to vectorial involves changing template logic making it harder. Also, images get mixed and it may be hard to notice when rescaling is being done in the wrong files.

I think it's easier to have the plugin be able to bypass processing vectorial images and just invoke the template with the original file path.

Thanks for your time.

PD: I'm new to Ruby, these are almost my first lines of code besides some basic Jekyll plugin.

wildlyinaccurate commented 3 years ago

Hey, thanks for your PR! My gut feel is that this logic would be better in your templates. Is there a reason this wouldn't work?

{% assign path = 'assets/vector.svg' %}
{% assign extension = path | slice: -3, 3 %}

{% if extension != 'svg' %}
  {% responsive_image_block %}
    path: {{ path }}
  {% endresponsive_image_block %}
{% else %}
  <img src="{{ path }}">
{% endif %}
berarma commented 3 years ago

It would work but having to repeat this code for every image isn't ideal. I will write a custom plugin to do it, or maybe an include file.

I just thought it could be useful for more users and wanted to give it a try.

I'll try now writing a custom plugin. It should be as easy.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

felixdivo commented 2 years ago

I would also find this very useful :)