public static function YouTube::getIdFromInput in Video Embed Field 8.2
Same name and namespace in other branches
- 8 src/Plugin/video_embed_field/Provider/YouTube.php \Drupal\video_embed_field\Plugin\video_embed_field\Provider\YouTube::getIdFromInput()
Get the ID of the video from user input.
Parameters
string $input: Input a user would enter into a video field.
Return value
string The ID in whatever format makes sense for the provider.
Overrides ProviderPluginInterface::getIdFromInput
File
- src/
Plugin/ video_embed_field/ Provider/ YouTube.php, line 89
Class
- YouTube
- A YouTube provider plugin.
Namespace
Drupal\video_embed_field\Plugin\video_embed_field\ProviderCode
public static function getIdFromInput($input) {
preg_match('/^https?:\\/\\/(www\\.)?((?!.*list=)youtube\\.com\\/watch\\?.*v=|youtu\\.be\\/)(?<id>[0-9A-Za-z_-]*)/', $input, $matches);
return isset($matches['id']) ? $matches['id'] : FALSE;
}