statikbe/craft-video-parser

Parse youtube & vimeo url's to make embeds

5.0.1 2024-07-01 09:13 UTC

This package is auto-updated.

Last update: 2024-10-31 00:23:27 UTC


README

This is a little plugin to get the ID from a youtube of vimeo URL, so that it can be used to create a video embed.

Usage

The plugin comes with a twig function that you use like this:

{% set video = craft.videoparser.parse(entry.video) %}

It returns an object with the following properties:

  • Type (youtube or vimeo)
  • ID
  • embedSrc (specific to the type)
  • extraParts (url parameters separated by an &)

Then you can create your own embed as you see fit.

<iframe src="{{ video.embedSrc }}{{ video.extraParts ? '?'~video.extraParts }}" frameborder="0" width="500" height="300"></iframe>