{% if include.url contains "https://youtu.be/" %} {% assign youtube_id = include.url | replace: 'https://youtu.be/','' %} {% elsif include.url contains "https://www.youtube.com/watch?v=" %} {% assign youtube_id = include.url | replace: 'https://www.youtube.com/watch?v=','' %} {% else %} {% assign youtube_id = include.url %} {% endif %} {% assign youtube_id = youtube_id | split: "&" | first %} {% assign title = "" %} {% if include.title %} {% assign title = include.title %} {% endif %} {% if include.poster_image %} {% assign youtube_poster_image_url = include.poster_image %} {% capture poster_img %}{% picture youtube_poster_image {{youtube_poster_image_url}} --alt {{title}} %}{% endcapture %} {% else %} {% capture poster_img %}https://img.youtube.com/vi/{{youtube_id}}/maxresdefault.jpg{% endcapture %} {% endif %}