diff --git a/Model/Configuration.php b/Model/Configuration.php index d5c5e52..4ff36d1 100644 --- a/Model/Configuration.php +++ b/Model/Configuration.php @@ -376,6 +376,14 @@ public function getFormatsToPreserve() return ['png', 'webp', 'gif', 'svg']; } + /** + * @return array + */ + public function getSupportedVideoFormats() + { + return ['mp4', 'webm', 'ogv', 'mov', 'wmv']; + } + /** * @param string $file * @return string @@ -703,6 +711,10 @@ public function parseCloudinaryUrl($url, $publicId = null) $slug = \array_shift($_url); $parsed["type"] = ($parsed["cloudName"] && $slug === "video") ? "video" : "image"; + if (isset($parsed['extension'])) { + $parsed['type'] = (in_array($parsed['extension'], $this->getSupportedVideoFormats())) ? 'video' : 'image'; + } + $slug = \array_shift($_url); $parsed["transformations_string"] = ($slug === 'upload' ? '' : $slug) . implode('/', $_url); diff --git a/composer.json b/composer.json index f134e80..e7a13b8 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "cloudinary/cloudinary-magento2", "description": "Cloudinary Magento 2 Integration.", "type": "magento2-module", - "version": "1.19.90", + "version": "1.19.92", "license": "MIT", "require": { "cloudinary/cloudinary_php": ">=2.7 <=2.11.0" diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml index 2e5afe9..bdb7949 100644 --- a/etc/csp_whitelist.xml +++ b/etc/csp_whitelist.xml @@ -6,6 +6,8 @@ cloudinary.com *.cloudinary.com cdnjs.cloudflare.com + *.youtube.com + *.vimeo.com diff --git a/etc/module.xml b/etc/module.xml index 7de462a..e7c9b4e 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/frontend/web/js/load-player.js b/view/frontend/web/js/load-player.js index 8be12c8..0ed669a 100644 --- a/view/frontend/web/js/load-player.js +++ b/view/frontend/web/js/load-player.js @@ -10,8 +10,8 @@ define( [ - 'jquery', - 'jquery-ui-modules/widget' + 'jquery', + 'jquery-ui-modules/widget' ], function ($) { 'use strict'; @@ -59,19 +59,19 @@ define( */ _create: function () { switch (this.element.data('type')) { - case 'youtube': - this.element.videoYoutube(); - this._player = this.element.data('mageVideoYoutube'); + case 'youtube': + this.element.videoYoutube(); + this._player = this.element.data('mageVideoYoutube'); break; - case 'vimeo': - this.element.videoVimeo(); - this._player = this.element.data('mageVideoVimeo'); + case 'vimeo': + this.element.videoVimeo(); + this._player = this.element.data('mageVideoVimeo'); break; - case 'cloudinary': - this.element.videoCloudinary(); - this._player = this.element.data('mageVideoCloudinary'); + case 'cloudinary': + this.element.videoCloudinary(); + this._player = this.element.data('mageVideoCloudinary'); break; - default: + default: throw { name: 'Video Error', message: 'Unknown video type', @@ -82,7 +82,7 @@ define( toString: function () { return this.name + ': ' + this.message; } - }; + }; } }, @@ -226,11 +226,11 @@ define( */ onStateChange: function (data) { switch (window.parseInt(data.data, 10)) { - case 1: - self._playing = true; + case 1: + self._playing = true; break; - default: - self._playing = false; + default: + self._playing = false; break; } @@ -339,7 +339,7 @@ define( _create: function () { var timestamp, additionalParams = '', - src; + src, id; this._initialize(); timestamp = new Date().getTime(); @@ -357,27 +357,25 @@ define( this._code + timestamp + additionalParams; + id = 'vimeo' + this._code + timestamp; this.element.append( $('