2017 © Pedro Peláez
 

craft-plugin craft3-videoembedder

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

image

mikestecker/craft3-videoembedder

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  • Thursday, April 12, 2018
  • by mikestecker
  • Repository
  • 1 Watchers
  • 2 Stars
  • 244 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 4 % Grown

The README.md

Video Embedder plugin for Craft CMS 3.x

Screenshot, (*1)

Craft plugin to generate an embed URL from a YouTube or Vimeo URL. This plugin will be 100% free., (*2)

Ported over from Viget's Video Embed plugin for Craft 2.x., (*3)

Requirements

This plugin requires Craft CMS 3.0.0 or later., (*4)

Installation

To install Video Embedder, follow these steps:, (*5)

  1. Install with Composer via composer require mikestecker/craft-videoembedder from your project directory
  2. Install plugin in the Craft Control Panel under Settings > Plugins

Video Embedder works on Craft 3.x., (*6)

Video Embedder Overview

Video Embedder will take your YouTube or Vimeo URL's and convert the URL into an embed-friendly URL for use inside an iframe tag. Video Embedder also has a variable which will take the same URL and get the thumbnail image URL., (*7)

Using Video Embedder

Pass a YouTube or Vimeo URL to the getEmbedUrl variable and an embed URL will be returned. The plugin will check if the URL is valid and allows embedding. If it doesn't, it will return an empty string., (*8)

{% set embed = craft.videoEmbedder.getEmbedUrl('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if embed | length %}
    {{ embed }}
{% endif %}

Example:, (*9)

{% set embed = craft.videoEmbedder.getEmbedUrl('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if embed | length %}





{% endif %}

Output:, (*10)

<iframe src="//www.youtube.com/embed/6xWpo5Dn254"></iframe>

New in 1.0.5:, (*11)

getEmbedUrl will now accept optional parameters to YouTube and Vimeo URL's such as autoplay, rel, etc:, (*12)

{% set embed = craft.videoEmbedder.getEmbedUrl('https://www.youtube.com/watch?v=6xWpo5Dn254', {autoplay: 1, rel: 0, theme: 'dark'}) %}

Video Embedder will also pull the largest thumbnail URL from YouTube or Vimeo using the getVideoThumbnail variable., (*13)

{% set thumbnail = craft.videoEmbedder.getVideoThumbnail('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if thumbnail | length %}
    {{ thumbnail }}
{% endif %}

Output:, (*14)

//img.youtube.com/vi/6xWpo5Dn254/0.jpg

New in 1.0.5:, (*15)

Video Embedder will now generate the iframe code. Simple use the embed variable with your URL. You can also pass in optional parameters to YouTube and Vimeo URL's such as autoplay, rel, etc., (*16)

Basic example:, (*17)

{% set embed = craft.videoEmbedder.embed('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if embed | length %}
    {{ embed }}
{% endif %}

With parameters:, (*18)

{% set embed = craft.videoEmbedder.embed('https://www.youtube.com/watch?v=6xWpo5Dn254', {autoplay: 1, rel: 0, theme: 'dark'}) %}

These parameters will simply output at the end of the embed URL string and have only been tested with YouTube and Vimeo. Check with each provider for which parameters are supported., (*19)


New in 1.0.9:, (*20)

Return only the Vimeo or YouTube ID from the URL. This is helpful in use cases such as using it with Plyr, (*21)

Basic example:, (*22)

{% set videoUrl = 'https://www.youtube.com/watch?v=6xWpo5Dn254' %}
{% set videoId = craft.videoEmbedder.getVideoId(videoUrl) %}
{% set providerName = craft.videoEmbedder.getProviderName(videoUrl) %}

{% if videoId | length %}


{% endif %}

Video Embedder Roadmap

Some things to do, and ideas for potential features:, (*23)

  • [x] Add in the ability to actually generate the iframe HTML
  • [x] Add new Video URL fieldype (thanks @samuelbirch!)
  • [ ] Limit Video URL fieldtype to only allow for supported video URL's
  • [ ] Add support for more video providers (partially added with 1.0.5 by switching to using the Embed library)
  • [ ] Add more thumbnail size options
  • [ ] Testing

This is my first plugin and I'm not very experienced with plugin development. Feel free to fork away, add whatever you'd like to see and send me a pull request., (*24)

Brought to you by Mike Stecker, (*25)

The Versions

12/04 2018

v1.x-dev

1.9999999.9999999.9999999-dev

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

12/04 2018

1.0.9

1.0.9.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

07/03 2018

1.0.8

1.0.8.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

07/03 2018

1.0.7

1.0.7.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

20/02 2018

1.0.6

1.0.6.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

20/02 2018

1.0.5

1.0.5.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

29/01 2018

dev-master

9999999-dev

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

29/01 2018

1.0.4

1.0.4.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

13/12 2017

1.0.3

1.0.3.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

07/08 2017

1.0.2

1.0.2.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder

06/08 2017

1.0.1

1.0.1.0

Craft plugin to generate an embed URL from a YouTube or Vimeo URL.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft video embedder