Last active
August 29, 2015 14:21
-
-
Save jmuspratt/0494aaa48dc216e5d4c1 to your computer and use it in GitHub Desktop.
Assume we're in a Matrix field called postBody which contains different kinds of blocks. videoBlock has three fields: (1) a dropdown for videoService (youtube vs. vimeo), (2) a dropdown for videoAspectRatio (ratio-16-9, ratio-4-3, etc.), and (3) a text field for videoID.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if entry.postBody | length %} | |
<div class="post-body"> | |
{% for block in entry.postBody %} | |
{% switch block.type %} | |
{% case 'textBlock' %} | |
{{ block.text }} | |
{# cases for other blocks #} | |
{% case 'videoBlock' %} | |
<div class="media-embed {{ block.videoAspectRatio }}"> | |
{% switch block.videoService %} | |
{% case "youtube" %} | |
{# see youtube parameters at https://developers.google.com/youtube/player_parameters #} | |
<iframe class='youtube-player' type='text/html' src='http://www.youtube.com/embed/{{ block.videoID }}?version=3&theme=light&modestbranding=1&rel=0&fs=1&showsearch=0&showinfo=0&iv_load_policy=3&wmode=transparent' frameborder='0' allowfullscreen='true'></iframe> | |
{% case "vimeo" %} | |
{# see vimeo parameters at https://developer.vimeo.com/player/embedding #} | |
<iframe class="vimeo-player" src="https://player.vimeo.com/video/{{ block.videoID }}?title=0&portrait=0&badge=&byline=0&color=dddddd" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> | |
{% endswitch %} | |
</div> <!-- media-embed --> | |
{% endswitch %} | |
{% endfor %} | |
</div> <!-- post-body --> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment