wildlyinaccurate / jekyll-responsive-image

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

Question: How to pass a class through `responsive_image_block` #96

Closed jhogue closed 4 years ago

jhogue commented 4 years ago

Great plugin, thanks for all your work. I'm wondering why I can't seem to pass a class through the template when using the block. When I use the inline method it works… but this won't work for me:

{% responsive_image_block %}
  path: {{ image_path }}
  class: "taxonomy__img"
  cache: true
{% endresponsive_image_block %}

I've tried assigning the class name and passing it through with {{ image_class }}, I've tried no quotes, single quotes… nothing in the output for a class… I was hoping to achieve this:

<img src="/property-img/blue-coal/blue-coal-sclover-01.jpg" alt="" srcset="/property-img/r/400/blue-coal-sclover-01.jpg 400w" class="taxonomy__img" alt="" loading="lazy">

And apply a different class where I might be using the block. Thanks for any help or pointers.

jhogue commented 4 years ago

"Passed straight through the template as variables"…

Got it working. Closing issue

zcraber commented 1 year ago

"Passed straight through the template as variables"…

@jhogue I know this is an old thread. But is it possible for you to show an example of how you did it? Thank you.

Edit: Nevermind, I figured it out. Changed the class name in the template file.

jhogue commented 1 year ago

Yeah, sorry. I don't remember the use case and I looked through a few projects for this but couldn't find a place where I passed a class name variable through. What I might have done is used an external class on a wrapper to target these img tags and do any styling I needed that way.