Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahDeWachter committed Mar 1, 2024
2 parents 7e34db4 + 29e24e2 commit 8666c81
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.2.0 - 2024-03-01
### Added
- Added support for Youtube url parameters ([#1](https://github.com/statikbe/craft-video-parser/issues/1))


## 2.1.3 - 2023-12-8
### Fixed
- Fixed an issue where inputting an unparseable url would throw an error instead of returning null
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ 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 }}" frameborder="0" width="500" height="300"></iframe>
<iframe src="{{ video.embedSrc }}{{ video.extraParts ? '?'~video.extraParts }}" frameborder="0" width="500" height="300"></iframe>
````
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
"name": "statikbe/craft-video-parser",
"description": "Parse youtube & vimeo url's to make embeds",
"type": "craft-plugin",
"version": "2.1.3",
"version": "2.2.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"video-embed"
"video-embed",
"video",
"youtube",
"vimeo"
],
"support": {
"docs": "https://github.com/statikbe/craft-video-parser/blob/master/README.md",
"docs": "https://github.com/statikbe/craft-video-parser/blob/main/README.md",
"issues": "https://github.com/statikbe/craft-video-parser/issues"
},
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions src/models/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function str_contains($haystack, $needle)
$this->id = $match[1];
}

if (str_contains($url, '&')) {
$parts = explode('&', $url);
array_shift($parts);
$parts = preg_replace('/^t=(.*)s$/', "start=$1", $parts);
$this->extraParts = implode("&", $parts);
}

$this->getEmbedSrc();
} elseif (strpos($url, 'vimeo')) {
$this->type = Video::TYPE_VIMEO;
Expand Down

0 comments on commit 8666c81

Please sign in to comment.