2017 © Pedro Peláez
 

package twig-video-box

Twig extensions for making video embedding easy.

image

shadesoft/twig-video-box

Twig extensions for making video embedding easy.

  • Tuesday, July 24, 2018
  • by subbysnake
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

TwigVideoBox

Twig extensions for making video embedding easy., (*1)

Currently supports YouTube. Other video sharing sites will be available later., (*2)

Installation

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)

Including into Symfony 3-4 container (if autowire and autoconfigure is set to true)

# app/config/services.yml for Symfony 3 or config/services.yaml for Symfony 4

ShadeSoft\Twig\YouTubeExtension: ~

Including into Symfony 2 container

# app/config/services.yml

shadesoft.twig.video_box.youtube_extension:
    class: ShadeSoft\Twig\YouTubeExtension
    tags:
        - { name: twig.extension }

Including into Slim Framework's Twig view renderer

// src/dependencies.php

// ...
$container['view'] = function($c) {
    //...
    $view->addExtension(new ShadeSoft\Twig\YouTubeExtension);
    //...
}

Usage

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 #}

The Versions

24/07 2018

dev-master

9999999-dev https://github.com/ShadeSoft/TwigVideoBox

Twig extensions for making video embedding easy.

  Sources   Download

MIT

The Requires

 

twig video embed