statikbe/craft-video-parser

Parse youtube & vimeo url's to make embeds

5.0.0 2024-03-26 20:04 UTC

This package is auto-updated.

Last update: 2024-05-26 20:22:14 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>