How can I add styling to a regular video_tag in Liquid?

Hi,

I a regular video_tag that i want to add some styling to:

{{ section.settings.url | video_tag }}

I want to be able to add some style based on some settings.

{{ section.settings.url | video_tag: "margin-top: {{ section.settings.marginTop }}" }}

But it seems like i cant add it this way, i suppose its because im trying to reference {{ }} inside {{ }}. Does anyone know if its possible to achieve what im trying to do?

Hello @ertanb ,

Great try but it will never work.
Please try this one:


{{ section.settings.url | video_tag }}

Thanks

1 Like

Hi @Guleria ,

Thank you for your answer. Good solution on appending the section.id to the class.

I actually did some experiments after i posted it here and came up with this solution, if anyone would need to pass it directly to the video.

{%  assign myStyle = 'margin-top: ' | append: section.settings.marginTop %}
{{ section.settings.url | video_tag: style: myStyle }}

And it seems to be working.

1 Like

Great but inline css never be a good solution but still your solution is helpful if there is a much need of the inline css.