diff --git a/modules/cloudinary_video/src/Plugin/video_embed_field/Provider/Cloudinary.php b/modules/cloudinary_video/src/Plugin/video_embed_field/Provider/Cloudinary.php index 825e07da496d34bd1b522249a80b5778fd2c521b..49917bcd41da510a9f18d75088fa88791ce7fa68 100644 --- a/modules/cloudinary_video/src/Plugin/video_embed_field/Provider/Cloudinary.php +++ b/modules/cloudinary_video/src/Plugin/video_embed_field/Provider/Cloudinary.php @@ -43,7 +43,7 @@ class Cloudinary extends ProviderPluginBase { * The video format. */ protected function getVideoFormat() { - $info = pathinfo($this->getInput()); + $info = pathinfo($this->getVideoId()); return $info['extension']; } @@ -93,9 +93,7 @@ class Cloudinary extends ProviderPluginBase { * {@inheritdoc} */ public function getRemoteThumbnailUrl() { - [, $uri] = explode('://', $this->getInput()); - - $source = str_replace(".{$this->getVideoFormat()}", '.jpg', $uri); + $source = str_replace(".{$this->getVideoFormat()}", '.jpg', $this->getVideoId()); $options['secure'] = TRUE; $options['resource_type'] = 'video'; @@ -113,7 +111,7 @@ class Cloudinary extends ProviderPluginBase { * The url to use for remote video. */ public function getRemoteVideoUrl() { - [, $source] = explode('://', $this->getInput()); + $source = $this->getVideoId(); $options['secure'] = TRUE; $options['resource_type'] = 'video'; @@ -293,15 +291,16 @@ class Cloudinary extends ProviderPluginBase { * {@inheritdoc} */ public static function getIdFromInput($input) { - [, $source] = explode('://', $input, 2); - - if (preg_match('/^(.+)\.(.+)$/', $source, $matches)) { - return $matches[1]; + // Get public id from the video schema. + if (str_contains($input, 'cloudinary://')) { + return substr($input, strlen('cloudinary://')); } - \Drupal::messenger()->addError('We could not fetch id from the video URL.'); + if (str_contains($input, '/video/upload/')) { + \Drupal::messenger()->addWarning(t('External cloudinary URL is currently not supported.')); + } - return ''; + return FALSE; } }