How do you add inline styling to a media field?

Answered

Comments

2 comments

  • David Kortleven

    You can do this by first assigning/capturing a variable, and then add the style parameter to the img_tag filter:

    {% assign style_var = "color: #FED" %}
    {{ src | img_tag: srcset: srcsets, sizes: sizes, inline_crop_for: image.image, style: style_var %}

    Note that you can skip the assign variable if you have a fixed value for the style parameter. But if this is the case, you probably want to set the style in your stylesheet and not inline.

    1
    Comment actions Permalink
  • David Hakkert

    Thx! Got it to work this way! :) 

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.