File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ ) and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
6
6
7
+ ## 2.0.3 - 2024-04-01
8
+ ### Added
9
+ - Expand getYouTubeIdFromUrl to allow shortened YouTube URLs
10
+
7
11
## 2.0.0 - 2022-09-07
8
12
### Added
9
13
- Updated for Craft 4
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Generate an embed URL from a YouTube or Vimeo URL.
4
4
5
5
## Requirements
6
6
7
- This plugin requires Craft CMS 4.0.0-beta or later.
7
+ This plugin requires Craft CMS 4.0.0 or later.
8
8
9
9
## Installation
10
10
Original file line number Diff line number Diff line change 2
2
"name" : " viget/craft-video-embed" ,
3
3
"description" : " Generate an embed URL from a YouTube or Vimeo URL" ,
4
4
"type" : " craft-plugin" ,
5
- "version" : " 2.0.2 " ,
5
+ "version" : " 2.0.3 " ,
6
6
"keywords" : [
7
7
" craft" ,
8
8
" cms" ,
22
22
}
23
23
],
24
24
"require" : {
25
- "craftcms/cms" : " ^4.0.0-alpha "
25
+ "craftcms/cms" : " ^4.0.0"
26
26
},
27
27
"autoload" : {
28
28
"psr-4" : {
Original file line number Diff line number Diff line change @@ -60,15 +60,21 @@ public static function getYouTubeIdFromUrl(string $url): ?string
60
60
61
61
if ($ query ) {
62
62
parse_str ($ query , $ qs );
63
- return $ qs ['v ' ] ?? $ qs ['vi ' ] ?? null ;
63
+ if ($ qs ['v ' ] || $ qs ['vi ' ]) {
64
+ return $ qs ['v ' ] ?? $ qs ['vi ' ];
65
+ }
64
66
}
65
-
66
- // Deals with https://youtu.be/X9tg3J5OiYU URLs
67
+
68
+ /**
69
+ * Patterns:
70
+ * - https://www.youtube.com/watch?v=--HXLM8GuxA
71
+ * - https://youtu.be/--HXLM8GuxA?si=pNahKJLszKr8J00u
72
+ */
67
73
if ($ path ) {
68
74
$ explodedPath = explode ('/ ' , trim ($ path , '/ ' ));
69
75
return $ explodedPath [0 ] ?? null ;
70
76
}
71
-
77
+
72
78
return null ;
73
79
}
74
80
You can’t perform that action at this time.
0 commit comments