Skip to content

Commit

Permalink
new version 1.19.92
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronen-Michaeli-22 committed Dec 24, 2023
2 parents a48b325 + bb94992 commit cd520d2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 52 deletions.
12 changes: 12 additions & 0 deletions Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<value id="cloudinary_main" type="host">cloudinary.com</value>
<value id="cloudinary_wildcard" type="host">*.cloudinary.com</value>
<value id="cloudinary_cloudflare_cdnjs" type="host">cdnjs.cloudflare.com</value>
<value id="youtube_scripts" type="host">*.youtube.com</value>
<value id="vimeo_scripts" type="host">*.vimeo.com</value>
</values>
</policy>
<policy id="frame-src">
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Cloudinary_Cloudinary" setup_version="1.19.90">
<module name="Cloudinary_Cloudinary" setup_version="1.19.92">
<sequence>
<module name="Magento_ProductVideo"/>
<module name="Magento_PageBuilder"/>
Expand Down
98 changes: 48 additions & 50 deletions view/frontend/web/js/load-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

define(
[
'jquery',
'jquery-ui-modules/widget'
'jquery',
'jquery-ui-modules/widget'
],
function ($) {
'use strict';
Expand Down Expand Up @@ -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',
Expand All @@ -82,7 +82,7 @@ define(
toString: function () {
return this.name + ': ' + this.message;
}
};
};
}
},

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -339,7 +339,7 @@ define(
_create: function () {
var timestamp,
additionalParams = '',
src;
src, id;

this._initialize();
timestamp = new Date().getTime();
Expand All @@ -357,27 +357,25 @@ define(
this._code +
timestamp +
additionalParams;
id = 'vimeo' + this._code + timestamp;
this.element.append(
$('<iframe/>')
.attr('frameborder', 0)
.attr('id', 'vimeo' + this._code + timestamp)
.attr('width', this._width)
.attr('height', this._height)
.attr('src', src)
.attr('webkitallowfullscreen', '')
.attr('mozallowfullscreen', '')
.attr('allowfullscreen', '')
.attr('referrerPolicy', 'origin')
.attr('frameborder', 0)
.attr('id', id)
.attr('width', this._width)
.attr('height', this._height)
.attr('src', src)
.attr('webkitallowfullscreen', '')
.attr('mozallowfullscreen', '')
.attr('allowfullscreen', '')
.attr('referrerPolicy', 'origin')
);
this._player = window.$f(this.element.children(':first')[0]);

this._player = new Vimeo.Player(this.element.children(':first')[0]);
// Froogaloop throws error without a registered ready event
this._player.addEvent(
'ready',
function (id) {
$('#' + id).closest('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
}
);
this._player.ready().then(function () {
$('#' + id).closest('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
});
},

/**
Expand Down Expand Up @@ -426,22 +424,22 @@ define(
var elem = this.element;
elem.append(
$('<iframe/>')
.attr('frameborder', 0)
.attr('id', 'cloudinary' + this._code + (new Date().getTime()))
.attr('class', 'cld-video-player')
.attr('width', this._width)
.attr('height', this._height)
.attr('src', this._videoUrl.replace(/(^\w+:|^)/, ''))
.attr('webkitallowfullscreen', '')
.attr('mozallowfullscreen', '')
.attr('allowfullscreen', '')
.attr('referrerPolicy', 'origin')
.on(
"load",
function () {
elem.parent('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
}
)
.attr('frameborder', 0)
.attr('id', 'cloudinary' + this._code + (new Date().getTime()))
.attr('class', 'cld-video-player')
.attr('width', this._width)
.attr('height', this._height)
.attr('src', this._videoUrl.replace(/(^\w+:|^)/, ''))
.attr('webkitallowfullscreen', '')
.attr('mozallowfullscreen', '')
.attr('allowfullscreen', '')
.attr('referrerPolicy', 'origin')
.on(
"load",
function () {
elem.parent('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
}
)
);

},
Expand Down

0 comments on commit cd520d2

Please sign in to comment.