Skip to content
Snippets Groups Projects
Commit e732a416 authored by Oleksandr Kuzava's avatar Oleksandr Kuzava
Browse files

Improve detecting cloudinary video.

parent 1a04c978
Branches 2.x
Tags 2.0.0-alpha5
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment