dev-master
9999999-dev https://github.com/ShadeSoft/TwigVideoBoxTwig extensions for making video embedding easy.
MIT
The Requires
twig video embed
Wallogit.com
2017 © Pedro Peláez
Twig extensions for making video embedding easy.
Twig extensions for making video embedding easy., (*1)
Currently supports YouTube. Other video sharing sites will be available later., (*2)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)
$ composer require shadesoft/twig-video-box
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*4)
# app/config/services.yml for Symfony 3 or config/services.yaml for Symfony 4 ShadeSoft\Twig\YouTubeExtension: ~
# app/config/services.yml
shadesoft.twig.video_box.youtube_extension:
class: ShadeSoft\Twig\YouTubeExtension
tags:
- { name: twig.extension }
// src/dependencies.php
// ...
$container['view'] = function($c) {
//...
$view->addExtension(new ShadeSoft\Twig\YouTubeExtension);
//...
}
Add \ShadeSoft\Twig\YouTubeExtension to your Twig environment's dependencies (or include into one of the frameworks above), then you can use the filters:, (*5)
{{ 'youtube_video_id'|youtube }} {# Renders YouTube with the default dimensions (560x315) #}
{{ 'youtube_video_id'|youtube(640) }} {# Renders YouTube with the width given (640x315) #}
{{ 'youtube_video_id'|youtube(640, 480) }} {# Renders YouTube with both dimensions given (640x480) #}
{{ 'youtube_video_id'|youtube('100%') }} {# Renders YouTube with the width fluid (100% x 315px) #}
{% set content = '
Youtube video:, (*6)
http://youtu.be/video_id
' %}
{{ content|youtubeBoxes|raw }} {# Renders the div with the p and the embedded video inside content #}
{# With this you can render multiple video boxes in a html content, you can simply use any valid YouTube url to the video #}
{# The width and height parameters can be used here, too #}
Twig extensions for making video embedding easy.
MIT
twig video embed