https://github.com/vigetlabs/craft-videoembed
Craft plugin to generate an embed URL from a YouTube or Vimeo URL.
https://github.com/vigetlabs/craft-videoembed
craft-plugin craft3 craft4 craft5 craftcms
Last synced: about 1 year ago
JSON representation
Craft plugin to generate an embed URL from a YouTube or Vimeo URL.
- Host: GitHub
- URL: https://github.com/vigetlabs/craft-videoembed
- Owner: vigetlabs
- License: mit
- Created: 2015-09-17T19:47:37.000Z (almost 11 years ago)
- Default Branch: v3
- Last Pushed: 2025-02-04T01:22:41.000Z (over 1 year ago)
- Last Synced: 2025-03-30T12:35:02.336Z (about 1 year ago)
- Topics: craft-plugin, craft3, craft4, craft5, craftcms
- Language: PHP
- Homepage:
- Size: 111 KB
- Stars: 24
- Watchers: 26
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Video Embed plugin for Craft CMS 5.x
Generate an embed URL from a YouTube or Vimeo URL.
## Requirements
This plugin requires Craft CMS 5.0.0 or later.
## Installation
To install the plugin, follow these instructions.
****
1. Open your terminal and go to your Craft project:
cd /path/to/project
2. Then tell Composer to load the plugin:
composer require viget/craft-video-embed
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Video Embed.
## Using Video Embed
Pass a YouTube or Vimeo URL to the `getVideoData` method and a `VideoData` object is returned.
If the plugin is unable to parse the URL, `null` is returned.
- `type` - If the video is `youtube` or `vimeo`
- `id` - The ID of the video
- `image` - The thumbnail of the video (only works for Youtube)
- `embedUrl` - The URL you would use for the embed
- `url` - The link to the embedded video
**Example:**
```twig
{% set video = craft.videoEmbed.getVideoData('https://www.youtube.com/watch?v=6xWpo5Dn254') %}
{% if video %}
{% endif %}
```
**Output:**
```
```
***
Visit [code.viget.com](http://code.viget.com) to see more projects from [Viget.](https://viget.com)