Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Core/Image/Transformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Cloudinary\Cloudinary\Core\Image;

use Cloudinary\Cloudinary\Core\Image\Transformation\Crop;
use Cloudinary\Cloudinary\Core\Image\Transformation\DefaultImage;
use Cloudinary\Cloudinary\Core\Image\Transformation\Dimensions;
use Cloudinary\Cloudinary\Core\Image\Transformation\Dpr;
use Cloudinary\Cloudinary\Core\Image\Transformation\FetchFormat;
Expand All @@ -12,6 +13,7 @@

class Transformation
{
private $defaultImage;
private $gravity;
private $dimensions;
private $crop;
Expand All @@ -27,6 +29,12 @@ public function __construct()
$this->flags = [];
}

public function withDefaultImage(DefaultImage $defaultImage)
{
$this->defaultImage = trim((string)$defaultImage);
return $this;
}

public function withGravity(Gravity $gravity)
{
$this->gravity = $gravity;
Expand Down Expand Up @@ -93,7 +101,8 @@ public function build()
'width' => $this->dimensions ? $this->dimensions->getWidth() : null,
'height' => $this->dimensions ? $this->dimensions->getHeight() : null,
'dpr' => (string)$this->dpr,
'flags' => $this->flags
'flags' => $this->flags,
'default_image' => $this->defaultImage,
]
];
}
Expand Down
28 changes: 28 additions & 0 deletions Core/Image/Transformation/DefaultImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Cloudinary\Cloudinary\Core\Image\Transformation;

class DefaultImage
{
private $value;

private function __construct($value)
{
$this->value = $value;
}

public function __toString()
{
return $this->value;
}

public static function fromString($value)
{
return new DefaultImage($value);
}

public static function null()
{
return new DefaultImage(null);
}
}
13 changes: 12 additions & 1 deletion Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Cloudinary\Cloudinary\Core\Credentials;
use Cloudinary\Cloudinary\Core\Exception\InvalidCredentials;
use Cloudinary\Cloudinary\Core\Image\Transformation;
use Cloudinary\Cloudinary\Core\Image\Transformation\DefaultImage;
use Cloudinary\Cloudinary\Core\Image\Transformation\Dpr;
use Cloudinary\Cloudinary\Core\Image\Transformation\FetchFormat;
use Cloudinary\Cloudinary\Core\Image\Transformation\Freeform;
Expand Down Expand Up @@ -41,6 +42,7 @@ class Configuration implements ConfigurationInterface
const CONFIG_PATH_DEFAULT_QUALITY = 'cloudinary/transformations/cloudinary_image_quality';
const CONFIG_PATH_DEFAULT_DPR = 'cloudinary/transformations/cloudinary_image_dpr';
const CONFIG_PATH_DEFAULT_FETCH_FORMAT = 'cloudinary/transformations/cloudinary_fetch_format';
const CONFIG_PATH_DEFAULT_IMAGE = 'cloudinary/transformations/cloudinary_default_image';
const CONFIG_PATH_GLOBAL_FREEFORM = 'cloudinary/transformations/cloudinary_free_transform_global';

//= Lazyload
Expand Down Expand Up @@ -238,7 +240,8 @@ public function getDefaultTransformation()
->withQuality(Quality::fromString($this->getImageQuality()))
->withFetchFormat(FetchFormat::fromString($this->getFetchFormat()))
->withFreeform(Freeform::fromString($this->getDefaultGlobalFreeform()))
->withDpr(Dpr::fromString($this->getImageDpr()));
->withDpr(Dpr::fromString($this->getImageDpr()))
->withDefaultImage(DefaultImage::fromString($this->getCloudinaryDefaultImage()));
}

/**
Expand Down Expand Up @@ -324,6 +327,14 @@ public function getFetchFormat()
return $this->configReader->isSetFlag(self::CONFIG_PATH_DEFAULT_FETCH_FORMAT) ? FetchFormat::FETCH_FORMAT_AUTO : '';
}

/**
* @return string
*/
public function getCloudinaryDefaultImage()
{
return (string) $this->configReader->getValue(self::CONFIG_PATH_DEFAULT_IMAGE);
}

/**
* @return string
*/
Expand Down
1 change: 1 addition & 0 deletions Plugin/CatalogImportExport/Model/Import/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function aroundMove(\Magento\CatalogImportExport\Model\Import\Uploader $u
if ($this->parsedRemoteFileUrl['type'] === 'video') {
$cloudinaryVideosImportMap = $this->coreRegistry->registry('cloudinary_videos_import_map') ?: [];
$cloudinaryVideosImportMap["{$result['file']}"] = $this->parsedRemoteFileUrl["orig_url"];
$this->coreRegistry->unregister('cloudinary_videos_import_map');
$this->coreRegistry->register('cloudinary_videos_import_map', $cloudinaryVideosImportMap);
}
}
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.15.1",
"version": "1.15.2",
"license": "MIT",
"require": {
"cloudinary/cloudinary_php": "^1.20.0"
Expand Down
6 changes: 5 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
<comment>Set the DPR value for your images. A DPR value of 2.0 will generate and deliver hi-res images for better results on HiDPI devices such as Retina Displays.</comment>
<source_model>Cloudinary\Cloudinary\Model\Config\Source\Dropdown\Dpr</source_model>
</field>
<field id="cloudinary_free_transform_global" translate="label comment" type="text" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<field id="cloudinary_default_image" translate="label comment" type="text" sortOrder="5" showInDefault="4" showInWebsite="0" showInStore="0" canRestore="1">
<label>Default image</label>
<comment>The public ID and file extension of the image to use as a placeholder when an asset no longer exists (e.g. sample.jpg).</comment>
</field>
<field id="cloudinary_free_transform_global" translate="label comment" type="text" sortOrder="6" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Global Custom Transformation</label>
<comment><![CDATA[Add global custom transformations in addition to those selected above.<br>Custom transformations will be added to the default image transformations settings chosen above.<br>For information about the full range of transforms available see the <a href="http://cloudinary.com/documentation/image_transformation_reference" target="_blank" title="Cloudinary documentation">Cloudinary documentation</a>.<br>You may need to clear or rebuild the Magento block and full page caches to see the changes in the front end.]]></comment>
<backend_model>Cloudinary\Cloudinary\Model\Config\Backend\Free</backend_model>
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.15.1">
<module name="Cloudinary_Cloudinary" setup_version="1.15.2">
<sequence>
<module name="Magento_ProductVideo"/>
<module name="Magento_PageBuilder"/>
Expand Down
2 changes: 1 addition & 1 deletion marketplace.composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cloudinary/cloudinary",
"description": "Cloudinary Magento 2 Integration.",
"type": "magento2-module",
"version": "1.15.1",
"version": "1.15.2",
"license": "MIT",
"require": {
"cloudinary/cloudinary_php": "^1.20.0"
Expand Down