statikbe / craft-video-parser
Parse youtube & vimeo url's to make embeds
Installs: 9 980
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^5.0.0
Requires (Dev)
- codeception/codeception: ^5.0.0
- codeception/module-asserts: ^3.0.0
- codeception/module-yii2: ^1.0.1
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- vlucas/phpdotenv: ^5.0
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>