Version Notes
v1.1.0
* Fix bug when image sizes contain a decimal point
* Update to latest Cloudinary PHP Library
Download this release
Release Info
Developer | Cloudinary |
Extension | Cloudinary_Cloudinary |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
- app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php +5 -5
- app/code/community/Cloudinary/Cloudinary/Helper/Configuration.php +14 -1
- app/code/community/Cloudinary/Cloudinary/Model/MediaCollectionCounter.php +1 -1
- app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php +1 -1
- app/code/community/Cloudinary/Cloudinary/Model/Resource/Media/Collection.php +0 -1
- app/code/community/Cloudinary/Cloudinary/Model/Resource/Media/Collection/Interface.php +0 -8
- app/code/community/Cloudinary/Cloudinary/Model/Resource/Synchronisation/Collection.php +4 -2
- app/code/community/Cloudinary/Cloudinary/etc/config.xml +5 -2
- lib/Cloudinary/Api.php +2 -1
- lib/Cloudinary/Cloudinary.php +156 -15
- lib/Cloudinary/Helpers.php +98 -1
- lib/Cloudinary/Uploader.php +33 -20
- lib/CloudinaryExtension/CloudinaryImageProvider.php +1 -0
- lib/CloudinaryExtension/Configuration.php +18 -0
- lib/CloudinaryExtension/Image/Transformation/Dimensions.php +2 -2
- package.xml +7 -13
app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php
CHANGED
@@ -22,10 +22,10 @@ class Cloudinary_Cloudinary_Helper_Autoloader
|
|
22 |
spl_autoload_register(
|
23 |
function ($className) {
|
24 |
if(
|
25 |
-
strpos($className,
|
26 |
-
strpos($className,
|
27 |
) {
|
28 |
-
include_once preg_replace(
|
29 |
}
|
30 |
}
|
31 |
);
|
@@ -39,8 +39,8 @@ class Cloudinary_Cloudinary_Helper_Autoloader
|
|
39 |
|
40 |
spl_autoload_register(
|
41 |
function ($className) use ($libFolder) {
|
42 |
-
if($className ===
|
43 |
-
foreach(new GlobIterator($libFolder . DS .
|
44 |
include_once $phpFile;
|
45 |
}
|
46 |
}
|
22 |
spl_autoload_register(
|
23 |
function ($className) {
|
24 |
if(
|
25 |
+
strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_EXTENSION_LIB_PATH . '\\') === 0 ||
|
26 |
+
strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH . '\\') === 0
|
27 |
) {
|
28 |
+
include_once preg_replace(Cloudinary_Cloudinary_Helper_Autoloader::CONVERT_CLASS_TO_PATH_REGEX, '/', $className) . '.php';
|
29 |
}
|
30 |
}
|
31 |
);
|
39 |
|
40 |
spl_autoload_register(
|
41 |
function ($className) use ($libFolder) {
|
42 |
+
if($className === Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH) {
|
43 |
+
foreach(new GlobIterator($libFolder . DS . Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH . DS . '*.php') as $phpFile) {
|
44 |
include_once $phpFile;
|
45 |
}
|
46 |
}
|
app/code/community/Cloudinary/Cloudinary/Helper/Configuration.php
CHANGED
@@ -28,6 +28,8 @@ class Cloudinary_Cloudinary_Helper_Configuration extends Mage_Core_Helper_Abstra
|
|
28 |
|
29 |
const STATUS_DISABLED = 0;
|
30 |
|
|
|
|
|
31 |
public function buildCredentials()
|
32 |
{
|
33 |
$environmentVariable = CloudinaryEnvironmentVariable::fromString($this->getEnvironmentVariable());
|
@@ -79,12 +81,23 @@ class Cloudinary_Cloudinary_Helper_Configuration extends Mage_Core_Helper_Abstra
|
|
79 |
$this->_setStoreConfig(self::CONFIG_PATH_ENABLED, self::STATUS_DISABLED);
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
public function buildConfiguration()
|
83 |
{
|
84 |
$config = Configuration::fromEnvironmentVariable(
|
85 |
CloudinaryEnvironmentVariable::fromString($this->getEnvironmentVariable())
|
86 |
);
|
87 |
|
|
|
|
|
88 |
if($this->getCdnSubdomainFlag()) {
|
89 |
$config->enableCdnSubdomain();
|
90 |
}
|
@@ -105,4 +118,4 @@ class Cloudinary_Cloudinary_Helper_Configuration extends Mage_Core_Helper_Abstra
|
|
105 |
$config->saveConfig($configPath, $value)->reinit();
|
106 |
}
|
107 |
|
108 |
-
}
|
28 |
|
29 |
const STATUS_DISABLED = 0;
|
30 |
|
31 |
+
const USER_PLATFORM_TEMPLATE = 'CloudinaryMagento/%s (Magento %s)';
|
32 |
+
|
33 |
public function buildCredentials()
|
34 |
{
|
35 |
$environmentVariable = CloudinaryEnvironmentVariable::fromString($this->getEnvironmentVariable());
|
81 |
$this->_setStoreConfig(self::CONFIG_PATH_ENABLED, self::STATUS_DISABLED);
|
82 |
}
|
83 |
|
84 |
+
public function getUserPlatform()
|
85 |
+
{
|
86 |
+
return sprintf(
|
87 |
+
self::USER_PLATFORM_TEMPLATE,
|
88 |
+
Mage::getConfig()->getModuleConfig('Cloudinary_Cloudinary')->version,
|
89 |
+
Mage::getVersion()
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
public function buildConfiguration()
|
94 |
{
|
95 |
$config = Configuration::fromEnvironmentVariable(
|
96 |
CloudinaryEnvironmentVariable::fromString($this->getEnvironmentVariable())
|
97 |
);
|
98 |
|
99 |
+
$config->setUserPlatform($this->getUserPlatform());
|
100 |
+
|
101 |
if($this->getCdnSubdomainFlag()) {
|
102 |
$config->enableCdnSubdomain();
|
103 |
}
|
118 |
$config->saveConfig($configPath, $value)->reinit();
|
119 |
}
|
120 |
|
121 |
+
}
|
app/code/community/Cloudinary/Cloudinary/Model/MediaCollectionCounter.php
CHANGED
@@ -5,7 +5,7 @@ class Cloudinary_Cloudinary_Model_MediaCollectionCounter implements Countable
|
|
5 |
|
6 |
private $_collections = array();
|
7 |
|
8 |
-
public function addCollection(
|
9 |
{
|
10 |
$this->_collections[] = $collection;
|
11 |
|
5 |
|
6 |
private $_collections = array();
|
7 |
|
8 |
+
public function addCollection(Varien_Data_Collection $collection)
|
9 |
{
|
10 |
$this->_collections[] = $collection;
|
11 |
|
app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php
CHANGED
@@ -4,7 +4,7 @@ use CloudinaryExtension\Migration\SynchronizedMediaRepository;
|
|
4 |
|
5 |
class Cloudinary_Cloudinary_Model_Resource_Cms_Synchronisation_Collection
|
6 |
extends Mage_Cms_Model_Wysiwyg_Images_Storage_Collection
|
7 |
-
implements SynchronizedMediaRepository
|
8 |
{
|
9 |
|
10 |
public function __construct()
|
4 |
|
5 |
class Cloudinary_Cloudinary_Model_Resource_Cms_Synchronisation_Collection
|
6 |
extends Mage_Cms_Model_Wysiwyg_Images_Storage_Collection
|
7 |
+
implements SynchronizedMediaRepository
|
8 |
{
|
9 |
|
10 |
public function __construct()
|
app/code/community/Cloudinary/Cloudinary/Model/Resource/Media/Collection.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
class Cloudinary_Cloudinary_Model_Resource_Media_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
4 |
-
implements Cloudinary_Cloudinary_Model_Resource_Media_Collection_Interface
|
5 |
{
|
6 |
|
7 |
protected function _construct()
|
1 |
<?php
|
2 |
|
3 |
class Cloudinary_Cloudinary_Model_Resource_Media_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
|
|
4 |
{
|
5 |
|
6 |
protected function _construct()
|
app/code/community/Cloudinary/Cloudinary/Model/Resource/Media/Collection/Interface.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
interface Cloudinary_Cloudinary_Model_Resource_Media_Collection_Interface
|
4 |
-
{
|
5 |
-
|
6 |
-
public function getSize();
|
7 |
-
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Cloudinary/Cloudinary/Model/Resource/Synchronisation/Collection.php
CHANGED
@@ -4,7 +4,7 @@ use CloudinaryExtension\Migration\SynchronizedMediaRepository;
|
|
4 |
|
5 |
class Cloudinary_Cloudinary_Model_Resource_Synchronisation_Collection
|
6 |
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
7 |
-
implements SynchronizedMediaRepository
|
8 |
{
|
9 |
|
10 |
protected function _construct()
|
@@ -33,8 +33,10 @@ class Cloudinary_Cloudinary_Model_Resource_Synchronisation_Collection
|
|
33 |
|
34 |
public function findUnsynchronisedImages($limit=200)
|
35 |
{
|
|
|
|
|
36 |
$this->getSelect()
|
37 |
-
->joinRight(
|
38 |
->where('cloudinary_synchronisation_id is null')
|
39 |
->limit($limit)
|
40 |
;
|
4 |
|
5 |
class Cloudinary_Cloudinary_Model_Resource_Synchronisation_Collection
|
6 |
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
7 |
+
implements SynchronizedMediaRepository
|
8 |
{
|
9 |
|
10 |
protected function _construct()
|
33 |
|
34 |
public function findUnsynchronisedImages($limit=200)
|
35 |
{
|
36 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('cloudinary_cloudinary/catalog_media_gallery');
|
37 |
+
|
38 |
$this->getSelect()
|
39 |
+
->joinRight($tableName, 'value_id=media_gallery_id', '*')
|
40 |
->where('cloudinary_synchronisation_id is null')
|
41 |
->limit($limit)
|
42 |
;
|
app/code/community/Cloudinary/Cloudinary/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Cloudinary_Cloudinary>
|
5 |
-
<version>
|
6 |
</Cloudinary_Cloudinary>
|
7 |
</modules>
|
8 |
<global>
|
@@ -41,6 +41,9 @@
|
|
41 |
<migration>
|
42 |
<table>cloudinary_migration</table>
|
43 |
</migration>
|
|
|
|
|
|
|
44 |
</entities>
|
45 |
</cloudinary_resource>
|
46 |
</models>
|
@@ -166,4 +169,4 @@
|
|
166 |
</updates>
|
167 |
</layout>
|
168 |
</adminhtml>
|
169 |
-
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Cloudinary_Cloudinary>
|
5 |
+
<version>1.1.0</version>
|
6 |
</Cloudinary_Cloudinary>
|
7 |
</modules>
|
8 |
<global>
|
41 |
<migration>
|
42 |
<table>cloudinary_migration</table>
|
43 |
</migration>
|
44 |
+
<catalog_media_gallery>
|
45 |
+
<table>catalog_product_entity_media_gallery</table>
|
46 |
+
</catalog_media_gallery>
|
47 |
</entities>
|
48 |
</cloudinary_resource>
|
49 |
</models>
|
169 |
</updates>
|
170 |
</layout>
|
171 |
</adminhtml>
|
172 |
+
</config>
|
lib/Cloudinary/Api.php
CHANGED
@@ -222,7 +222,7 @@ class Api {
|
|
222 |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
223 |
curl_setopt($ch, CURLOPT_USERPWD, "{$api_key}:{$api_secret}");
|
224 |
curl_setopt($ch, CURLOPT_CAINFO,realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR."cacert.pem");
|
225 |
-
curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::
|
226 |
curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
|
227 |
$response = $this->execute($ch);
|
228 |
$curl_error = NULL;
|
@@ -246,6 +246,7 @@ class Api {
|
|
246 |
|
247 |
# Based on http://snipplr.com/view/17242/
|
248 |
protected function execute($ch) {
|
|
|
249 |
$string = curl_exec($ch);
|
250 |
$headers = array();
|
251 |
$content = '';
|
222 |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
223 |
curl_setopt($ch, CURLOPT_USERPWD, "{$api_key}:{$api_secret}");
|
224 |
curl_setopt($ch, CURLOPT_CAINFO,realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR."cacert.pem");
|
225 |
+
curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::userAgent());
|
226 |
curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
|
227 |
$response = $this->execute($ch);
|
228 |
$curl_error = NULL;
|
246 |
|
247 |
# Based on http://snipplr.com/view/17242/
|
248 |
protected function execute($ch) {
|
249 |
+
\Mage::log(\Cloudinary::userAgent());
|
250 |
$string = curl_exec($ch);
|
251 |
$headers = array();
|
252 |
$content = '';
|
lib/Cloudinary/Cloudinary.php
CHANGED
@@ -6,14 +6,48 @@ class Cloudinary {
|
|
6 |
const OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net";
|
7 |
const AKAMAI_SHARED_CDN = "res.cloudinary.com";
|
8 |
const SHARED_CDN = "res.cloudinary.com";
|
9 |
-
const VERSION = "1.0.17";
|
10 |
-
const USER_AGENT = "cld-php-1.0.17";
|
11 |
const BLANK = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
public static $DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = array("width"=>"auto", "crop"=>"limit");
|
13 |
|
14 |
private static $config = NULL;
|
15 |
public static $JS_CONFIG_PARAMS = array("api_key", "cloud_name", "private_cdn", "secure_distribution", "cdn_subdomain");
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
public static function config($values = NULL) {
|
18 |
if (self::$config == NULL) {
|
19 |
self::reset_config();
|
@@ -115,9 +149,8 @@ class Cloudinary {
|
|
115 |
}
|
116 |
|
117 |
private static function generate_base_transformation($base_transformation) {
|
118 |
-
|
119 |
-
|
120 |
-
Cloudinary::generate_transformation_string(array("transformation"=>$base_transformation));
|
121 |
}
|
122 |
|
123 |
// Warning: $options are being destructively updated!
|
@@ -174,10 +207,56 @@ class Cloudinary {
|
|
174 |
$flags = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "flags")), ".");
|
175 |
$dpr = Cloudinary::option_consume($options, "dpr", Cloudinary::config_get("dpr"));
|
176 |
|
177 |
-
$
|
178 |
-
$
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
foreach ($simple_params as $param=>$option) {
|
182 |
$params[$param] = Cloudinary::option_consume($options, $option);
|
183 |
}
|
@@ -202,6 +281,48 @@ class Cloudinary {
|
|
202 |
}
|
203 |
return implode("/", array_filter($base_transformations));
|
204 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
// Warning: $options are being destructively updated!
|
207 |
public static function cloudinary_url($source, &$options=array()) {
|
@@ -344,12 +465,12 @@ class Cloudinary {
|
|
344 |
$shared_domain = ($secure_distribution == Cloudinary::SHARED_CDN);
|
345 |
}
|
346 |
|
347 |
-
if (
|
348 |
$secure_cdn_subdomain = $cdn_subdomain ;
|
349 |
}
|
350 |
|
351 |
if ($secure_cdn_subdomain) {
|
352 |
-
$secure_distribution = str_replace('res.cloudinary.com', "res-" . ((crc32($source) % 5) + 1) . "cloudinary.com", $secure_distribution);
|
353 |
}
|
354 |
|
355 |
$prefix = "https://" . $secure_distribution;
|
@@ -459,10 +580,30 @@ class Cloudinary {
|
|
459 |
$to_sign = implode("&", array_map($join_pair, array_keys($params), array_values($params)));
|
460 |
return sha1($to_sign . $api_secret);
|
461 |
}
|
462 |
-
|
463 |
-
|
464 |
-
$
|
465 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
}
|
467 |
}
|
468 |
|
6 |
const OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net";
|
7 |
const AKAMAI_SHARED_CDN = "res.cloudinary.com";
|
8 |
const SHARED_CDN = "res.cloudinary.com";
|
|
|
|
|
9 |
const BLANK = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
10 |
+
const RANGE_VALUE_RE = '/^(?P<value>(\d+\.)?\d+)(?P<modifier>[%pP])?$/';
|
11 |
+
const RANGE_RE = '/^(\d+\.)?\d+[%pP]?\.\.(\d+\.)?\d+[%pP]?$/';
|
12 |
+
|
13 |
+
const VERSION = "1.1.1";
|
14 |
+
/** @internal Do not change this value */
|
15 |
+
const USER_AGENT = "CloudinaryPHP/1.1.1";
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Additional information to be passed with the USER_AGENT, e.g. "CloudinaryMagento/1.0.1". This value is set in platform-specific
|
19 |
+
* implementations that use cloudinary_php.
|
20 |
+
*
|
21 |
+
* The format of the value should be <ProductName>/Version[ (comment)].
|
22 |
+
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
23 |
+
*
|
24 |
+
* <b>Do not set this value in application code!</b>
|
25 |
+
*
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
public static $USER_PLATFORM = "";
|
29 |
+
|
30 |
public static $DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = array("width"=>"auto", "crop"=>"limit");
|
31 |
|
32 |
private static $config = NULL;
|
33 |
public static $JS_CONFIG_PARAMS = array("api_key", "cloud_name", "private_cdn", "secure_distribution", "cdn_subdomain");
|
34 |
|
35 |
+
/**
|
36 |
+
* Provides the USER_AGENT string that is passed to the Cloudinary servers.
|
37 |
+
*
|
38 |
+
* Prepends {@link $USER_PLATFORM} if it is defined.
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public static function userAgent()
|
43 |
+
{
|
44 |
+
if (self::$USER_PLATFORM == "") {
|
45 |
+
return self::USER_AGENT;
|
46 |
+
} else {
|
47 |
+
return self::$USER_PLATFORM . " " . self::USER_AGENT;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
public static function config($values = NULL) {
|
52 |
if (self::$config == NULL) {
|
53 |
self::reset_config();
|
149 |
}
|
150 |
|
151 |
private static function generate_base_transformation($base_transformation) {
|
152 |
+
$options = is_array($base_transformation) ? $base_transformation : array("transformation"=>$base_transformation);
|
153 |
+
return Cloudinary::generate_transformation_string($options);
|
|
|
154 |
}
|
155 |
|
156 |
// Warning: $options are being destructively updated!
|
207 |
$flags = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "flags")), ".");
|
208 |
$dpr = Cloudinary::option_consume($options, "dpr", Cloudinary::config_get("dpr"));
|
209 |
|
210 |
+
$duration = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "duration"));
|
211 |
+
$start_offset = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "start_offset"));
|
212 |
+
$end_offset = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "end_offset"));
|
213 |
+
$offset = Cloudinary::split_range(Cloudinary::option_consume($options, "offset"));
|
214 |
+
if (!empty($offset)) {
|
215 |
+
$start_offset = Cloudinary::norm_range_value($offset[0]);
|
216 |
+
$end_offset = Cloudinary::norm_range_value($offset[1]);
|
217 |
+
}
|
218 |
+
|
219 |
+
$video_codec = Cloudinary::process_video_codec_param(Cloudinary::option_consume($options, "video_codec"));
|
220 |
+
|
221 |
+
$params = array(
|
222 |
+
"a" => $angle,
|
223 |
+
"b" => $background,
|
224 |
+
"bo" => $border,
|
225 |
+
"c" => $crop,
|
226 |
+
"co" => $color,
|
227 |
+
"dpr" => $dpr,
|
228 |
+
"du" => $duration,
|
229 |
+
"e" => $effect,
|
230 |
+
"eo" => $end_offset,
|
231 |
+
"fl" => $flags,
|
232 |
+
"h" => $height,
|
233 |
+
"so" => $start_offset,
|
234 |
+
"t" => $named_transformation,
|
235 |
+
"vc" => $video_codec,
|
236 |
+
"w" => $width);
|
237 |
+
|
238 |
+
$simple_params = array(
|
239 |
+
"ac" => "audio_codec",
|
240 |
+
"af" => "audio_frequency",
|
241 |
+
"br" => "bit_rate",
|
242 |
+
"cs" => "color_space",
|
243 |
+
"d" => "default_image",
|
244 |
+
"dl" => "delay",
|
245 |
+
"dn" => "density",
|
246 |
+
"f" => "fetch_format",
|
247 |
+
"g" => "gravity",
|
248 |
+
"l" => "overlay",
|
249 |
+
"o" => "opacity",
|
250 |
+
"p" => "prefix",
|
251 |
+
"pg" => "page",
|
252 |
+
"q" => "quality",
|
253 |
+
"r" => "radius",
|
254 |
+
"u" => "underlay",
|
255 |
+
"vs" => "video_sampling",
|
256 |
+
"x" => "x",
|
257 |
+
"y" => "y",
|
258 |
+
"z" => "zoom");
|
259 |
+
|
260 |
foreach ($simple_params as $param=>$option) {
|
261 |
$params[$param] = Cloudinary::option_consume($options, $option);
|
262 |
}
|
281 |
}
|
282 |
return implode("/", array_filter($base_transformations));
|
283 |
}
|
284 |
+
|
285 |
+
private static function split_range($range) {
|
286 |
+
if (is_array($range) && count($range) >= 2) {
|
287 |
+
return array($range[0], end($range));
|
288 |
+
} else if (is_string($range) && preg_match(Cloudinary::RANGE_RE, $range) == 1) {
|
289 |
+
return explode("..", $range, 2);
|
290 |
+
} else {
|
291 |
+
return NULL;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
private static function norm_range_value($value) {
|
296 |
+
if (empty($value)) {
|
297 |
+
return NULL;
|
298 |
+
}
|
299 |
+
|
300 |
+
preg_match(Cloudinary::RANGE_VALUE_RE, $value, $matches);
|
301 |
+
|
302 |
+
if (empty($matches)) {
|
303 |
+
return NULL;
|
304 |
+
}
|
305 |
+
|
306 |
+
$modifier = '';
|
307 |
+
if (!empty($matches['modifier'])) {
|
308 |
+
$modifier = 'p';
|
309 |
+
}
|
310 |
+
return $matches['value'] . $modifier;
|
311 |
+
}
|
312 |
+
|
313 |
+
private static function process_video_codec_param($param) {
|
314 |
+
$out_param = $param;
|
315 |
+
if (is_array($out_param)) {
|
316 |
+
$out_param = $param['codec'];
|
317 |
+
if (array_key_exists('profile', $param)) {
|
318 |
+
$out_param = $out_param . ':' . $param['profile'];
|
319 |
+
if (array_key_exists('level', $param)) {
|
320 |
+
$out_param = $out_param . ':' . $param['level'];
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
return $out_param;
|
325 |
+
}
|
326 |
|
327 |
// Warning: $options are being destructively updated!
|
328 |
public static function cloudinary_url($source, &$options=array()) {
|
465 |
$shared_domain = ($secure_distribution == Cloudinary::SHARED_CDN);
|
466 |
}
|
467 |
|
468 |
+
if (is_null($secure_cdn_subdomain) && $shared_domain) {
|
469 |
$secure_cdn_subdomain = $cdn_subdomain ;
|
470 |
}
|
471 |
|
472 |
if ($secure_cdn_subdomain) {
|
473 |
+
$secure_distribution = str_replace('res.cloudinary.com', "res-" . ((crc32($source) % 5) + 1) . ".cloudinary.com", $secure_distribution);
|
474 |
}
|
475 |
|
476 |
$prefix = "https://" . $secure_distribution;
|
580 |
$to_sign = implode("&", array_map($join_pair, array_keys($params), array_values($params)));
|
581 |
return sha1($to_sign . $api_secret);
|
582 |
}
|
583 |
+
|
584 |
+
public static function html_attrs($options, $only = NULL) {
|
585 |
+
$attrs = array();
|
586 |
+
foreach($options as $k => $v) {
|
587 |
+
$key = $k;
|
588 |
+
$value = $v;
|
589 |
+
if (is_int($k)) {
|
590 |
+
$key = $v;
|
591 |
+
$value = "";
|
592 |
+
}
|
593 |
+
if (is_array($only) && array_search($key, $only) !== FALSE || !is_array($only)) {
|
594 |
+
$attrs[$key] = $value;
|
595 |
+
}
|
596 |
+
}
|
597 |
+
ksort($attrs);
|
598 |
+
|
599 |
+
$join_pair = function($key, $value) {
|
600 |
+
$out = $key;
|
601 |
+
if (!empty($value)) {
|
602 |
+
$out .= '=\'' . $value . '\'';
|
603 |
+
}
|
604 |
+
return $out;
|
605 |
+
};
|
606 |
+
return implode(" ", array_map($join_pair, array_keys($attrs), array_values($attrs)));
|
607 |
}
|
608 |
}
|
609 |
|
lib/Cloudinary/Helpers.php
CHANGED
@@ -4,7 +4,8 @@ namespace {
|
|
4 |
function cl_upload_url($options = array())
|
5 |
{
|
6 |
if (!@$options["resource_type"]) $options["resource_type"] = "auto";
|
7 |
-
|
|
|
8 |
}
|
9 |
|
10 |
function cl_upload_tag_params($options = array())
|
@@ -24,6 +25,11 @@ namespace {
|
|
24 |
}
|
25 |
|
26 |
function cl_image_upload_tag($field, $options = array())
|
|
|
|
|
|
|
|
|
|
|
27 |
{
|
28 |
$html_options = Cloudinary::option_get($options, "html", array());
|
29 |
|
@@ -37,6 +43,7 @@ namespace {
|
|
37 |
"data-cloudinary-field" => $field,
|
38 |
"class" => implode(" ", $classes),
|
39 |
));
|
|
|
40 |
return '<input ' . Cloudinary::html_attrs($tag_options) . '/>';
|
41 |
}
|
42 |
|
@@ -148,4 +155,94 @@ namespace {
|
|
148 |
return "<link rel='stylesheet' type='text/css' href='" . cl_sprite_url($tag, $options) . "'>";
|
149 |
}
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
4 |
function cl_upload_url($options = array())
|
5 |
{
|
6 |
if (!@$options["resource_type"]) $options["resource_type"] = "auto";
|
7 |
+
$endpoint = array_key_exists('chunk_size', $options) ? 'upload_chunked' : 'upload';
|
8 |
+
return Cloudinary::cloudinary_api_url($endpoint, $options);
|
9 |
}
|
10 |
|
11 |
function cl_upload_tag_params($options = array())
|
25 |
}
|
26 |
|
27 |
function cl_image_upload_tag($field, $options = array())
|
28 |
+
{
|
29 |
+
return cl_upload_tag($field, $options);
|
30 |
+
}
|
31 |
+
|
32 |
+
function cl_upload_tag($field, $options = array())
|
33 |
{
|
34 |
$html_options = Cloudinary::option_get($options, "html", array());
|
35 |
|
43 |
"data-cloudinary-field" => $field,
|
44 |
"class" => implode(" ", $classes),
|
45 |
));
|
46 |
+
if (array_key_exists('chunk_size', $options)) $tag_options['data-max-chunk-size'] = $options['chunk_size'];
|
47 |
return '<input ' . Cloudinary::html_attrs($tag_options) . '/>';
|
48 |
}
|
49 |
|
155 |
return "<link rel='stylesheet' type='text/css' href='" . cl_sprite_url($tag, $options) . "'>";
|
156 |
}
|
157 |
|
158 |
+
function default_poster_options() { return array( 'format' => 'jpg', 'resource_type' => 'video' ); }
|
159 |
+
function default_source_types() { return array('webm', 'mp4', 'ogv'); }
|
160 |
+
# Returns a url for the given source with +options+
|
161 |
+
function cl_video_path($source, $options = array()) {
|
162 |
+
$options = array_merge( array('resource_type' => 'video'), $options);
|
163 |
+
return cloudinary_url_internal($source, $options);
|
164 |
+
}
|
165 |
+
|
166 |
+
# Returns an HTML <tt>img</tt> tag with the thumbnail for the given video +source+ and +options+
|
167 |
+
function cl_video_thumbnail_tag($source, $options = array()) {
|
168 |
+
return cl_image_tag($source, array_merge(default_poster_options(),$options));
|
169 |
+
}
|
170 |
+
|
171 |
+
# Returns a url for the thumbnail for the given video +source+ and +options+
|
172 |
+
function cl_video_thumbnail_path($source, $options = array()) {
|
173 |
+
$options = array_merge(default_poster_options(), $options);
|
174 |
+
return cloudinary_url_internal($source, $options);
|
175 |
+
}
|
176 |
+
|
177 |
+
# Creates an HTML video tag for the provided +source+
|
178 |
+
#
|
179 |
+
# ==== Options
|
180 |
+
# * <tt>source_types</tt> - Specify which source type the tag should include. defaults to webm, mp4 and ogv.
|
181 |
+
# * <tt>source_transformation</tt> - specific transformations to use for a specific source type.
|
182 |
+
# * <tt>poster</tt> - override default thumbnail:
|
183 |
+
# * url: provide an ad hoc url
|
184 |
+
# * options: with specific poster transformations and/or Cloudinary +:public_id+
|
185 |
+
#
|
186 |
+
# ==== Examples
|
187 |
+
# cl_video_tag("mymovie.mp4")
|
188 |
+
# cl_video_tag("mymovie.mp4", array('source_types' => 'webm'))
|
189 |
+
# cl_video_tag("mymovie.ogv", array('poster' => "myspecialplaceholder.jpg"))
|
190 |
+
# cl_video_tag("mymovie.webm", array('source_types' => array('webm', 'mp4'), 'poster' => array('effect' => 'sepia')))
|
191 |
+
function cl_video_tag($source, $options = array()) {
|
192 |
+
$source = preg_replace('/\.(' . implode('|', default_source_types()) . ')$/', '', $source);
|
193 |
+
|
194 |
+
$source_types = Cloudinary::option_consume($options, 'source_types', array());
|
195 |
+
$source_transformation = Cloudinary::option_consume($options, 'source_transformation', array());
|
196 |
+
$fallback = Cloudinary::option_consume($options, 'fallback_content', '');
|
197 |
+
|
198 |
+
if (empty($source_types)) {
|
199 |
+
$source_types = default_source_types();
|
200 |
+
}
|
201 |
+
$video_options = $options;
|
202 |
+
|
203 |
+
if (array_key_exists('poster', $video_options)) {
|
204 |
+
if (is_array($video_options['poster'])) {
|
205 |
+
if (array_key_exists('public_id', $video_options['poster'])) {
|
206 |
+
$video_options['poster'] = cloudinary_url_internal($video_options['poster']['public_id'], $video_options['poster']);
|
207 |
+
} else {
|
208 |
+
$video_options['poster'] = cl_video_thumbnail_path($source, $video_options['poster']);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
} else {
|
212 |
+
$video_options['poster'] = cl_video_thumbnail_path($source, $options);
|
213 |
+
}
|
214 |
+
|
215 |
+
if (empty($video_options['poster'])) unset($video_options['poster']);
|
216 |
+
|
217 |
+
|
218 |
+
$html = '<video ';
|
219 |
+
|
220 |
+
if (!array_key_exists('resource_type', $video_options)) $video_options['resource_type'] = 'video';
|
221 |
+
$multi_source = is_array($source_types);
|
222 |
+
if (!$multi_source){
|
223 |
+
$source .= '.' . $source_types;
|
224 |
+
}
|
225 |
+
$src = cloudinary_url_internal($source, $video_options);
|
226 |
+
if (!$multi_source) $video_options['src'] = $src;
|
227 |
+
if (isset($video_options["html_width"])) $video_options['width'] = Cloudinary::option_consume($video_options, 'html_width');
|
228 |
+
if (isset($video_options['html_height'])) $video_options['height'] = Cloudinary::option_consume($video_options, 'html_height');
|
229 |
+
$html .= Cloudinary::html_attrs($video_options ) . '>';
|
230 |
+
|
231 |
+
if ($multi_source) {
|
232 |
+
|
233 |
+
foreach($source_types as $source_type) {
|
234 |
+
$transformation = Cloudinary::option_consume($source_transformation, $source_type, array());
|
235 |
+
$transformation = array_merge($options, $transformation);
|
236 |
+
$src = cl_video_path($source . '.' . $source_type, $transformation);
|
237 |
+
$video_type = (($source_type == 'ogv') ? 'ogg' : $source_type);
|
238 |
+
$mime_type = "video/$video_type";
|
239 |
+
$html .= '<source '. Cloudinary::html_attrs(array('src' => $src, 'type' => $mime_type)) . '>';
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
$html .= $fallback;
|
245 |
+
$html .= '</video>';
|
246 |
+
return $html;
|
247 |
+
}
|
248 |
}
|
lib/Cloudinary/Uploader.php
CHANGED
@@ -65,17 +65,31 @@ namespace Cloudinary {
|
|
65 |
public static function upload_large($file, $options=array())
|
66 |
{
|
67 |
$src = fopen($file, 'r');
|
68 |
-
$temp_file_name = tempnam(sys_get_temp_dir(), 'cldupload.'
|
69 |
$upload = $upload_id = NULL;
|
70 |
-
$
|
71 |
-
$
|
|
|
|
|
72 |
while (!feof($src)) {
|
|
|
|
|
|
|
|
|
73 |
$dest = fopen($temp_file_name, 'w');
|
74 |
-
stream_copy_to_stream($src, $dest,
|
75 |
fclose($dest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
try {
|
77 |
$upload = Uploader::upload_large_part($temp_file_name, array_merge($options,
|
78 |
-
array("public_id"=>$public_id, "
|
79 |
} catch(\Exception $e) {
|
80 |
unlink($temp_file_name);
|
81 |
fclose($src);
|
@@ -94,17 +108,8 @@ namespace Cloudinary {
|
|
94 |
// Upload large raw files. Note that public_id should include an extension for best results.
|
95 |
public static function upload_large_part($file, $options=array())
|
96 |
{
|
97 |
-
$params =
|
98 |
-
|
99 |
-
"type" => \Cloudinary::option_get($options, "type"),
|
100 |
-
"backup" => \Cloudinary::option_get($options, "backup"),
|
101 |
-
"final" => \Cloudinary::option_get($options, "final"),
|
102 |
-
"part_number" => \Cloudinary::option_get($options, "part_number"),
|
103 |
-
"upload_id" => \Cloudinary::option_get($options, "upload_id"),
|
104 |
-
"tags" => implode(",", \Cloudinary::build_array(\Cloudinary::option_get($options, "tags"))),
|
105 |
-
"public_id" => \Cloudinary::option_get($options, "public_id")
|
106 |
-
);
|
107 |
-
return Uploader::call_api("upload_large", $params, array_merge($options, array("resource_type" => "raw")), $file);
|
108 |
}
|
109 |
|
110 |
public static function destroy($public_id, $options = array())
|
@@ -138,6 +143,8 @@ namespace Cloudinary {
|
|
138 |
"type" => \Cloudinary::option_get($options, "type"),
|
139 |
"callback" => \Cloudinary::option_get($options, "callback"),
|
140 |
"eager" => Uploader::build_eager(\Cloudinary::option_get($options, "eager")),
|
|
|
|
|
141 |
"headers" => Uploader::build_custom_headers(\Cloudinary::option_get($options, "headers")),
|
142 |
"tags" => \Cloudinary::encode_array(\Cloudinary::option_get($options, "tags")),
|
143 |
"face_coordinates" => \Cloudinary::encode_double_array(\Cloudinary::option_get($options, "face_coordinates")),
|
@@ -245,7 +252,7 @@ namespace Cloudinary {
|
|
245 |
|
246 |
$post_params = array();
|
247 |
if ($file) {
|
248 |
-
if (!preg_match('/^@|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/', $file)) {
|
249 |
if (function_exists("curl_file_create")) {
|
250 |
$post_params['file'] = curl_file_create($file);
|
251 |
$post_params['file']->setPostFilename($file);
|
@@ -258,13 +265,19 @@ namespace Cloudinary {
|
|
258 |
}
|
259 |
|
260 |
curl_setopt($ch, CURLOPT_POST, true);
|
261 |
-
|
|
|
262 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
|
263 |
curl_setopt($ch, CURLOPT_CAINFO,realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR."cacert.pem");
|
264 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
265 |
-
curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::
|
266 |
curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
268 |
$response = curl_exec($ch);
|
269 |
$curl_error = NULL;
|
270 |
if(curl_errno($ch))
|
65 |
public static function upload_large($file, $options=array())
|
66 |
{
|
67 |
$src = fopen($file, 'r');
|
68 |
+
$temp_file_name = tempnam(sys_get_temp_dir(), 'cldupload.' . pathinfo($file, PATHINFO_EXTENSION));
|
69 |
$upload = $upload_id = NULL;
|
70 |
+
$chunk_size = \Cloudinary::option_get($options, "chunk_size", 20000000);
|
71 |
+
$public_id = \Cloudinary::option_get($options, "public_id");
|
72 |
+
$index = 0;
|
73 |
+
$file_size = filesize($file);
|
74 |
while (!feof($src)) {
|
75 |
+
$current_loc = $index * $chunk_size;
|
76 |
+
if ($current_loc >= $file_size) {
|
77 |
+
break;
|
78 |
+
}
|
79 |
$dest = fopen($temp_file_name, 'w');
|
80 |
+
stream_copy_to_stream($src, $dest, $chunk_size);
|
81 |
fclose($dest);
|
82 |
+
if (phpversion() >= "5.3.0") {
|
83 |
+
clearstatcache(TRUE, $temp_file_name);
|
84 |
+
} else {
|
85 |
+
clearstatcache();
|
86 |
+
}
|
87 |
+
|
88 |
+
$temp_file_size = filesize($temp_file_name);
|
89 |
+
$range = "bytes ". $current_loc . "-" . ($current_loc + $temp_file_size - 1) . "/" . $file_size;
|
90 |
try {
|
91 |
$upload = Uploader::upload_large_part($temp_file_name, array_merge($options,
|
92 |
+
array("public_id"=>$public_id, "content_range"=>$range)));
|
93 |
} catch(\Exception $e) {
|
94 |
unlink($temp_file_name);
|
95 |
fclose($src);
|
108 |
// Upload large raw files. Note that public_id should include an extension for best results.
|
109 |
public static function upload_large_part($file, $options=array())
|
110 |
{
|
111 |
+
$params = Uploader::build_upload_params($options);
|
112 |
+
return Uploader::call_api("upload_chunked", $params, array_merge(array("resource_type" => "raw"), $options), $file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
public static function destroy($public_id, $options = array())
|
143 |
"type" => \Cloudinary::option_get($options, "type"),
|
144 |
"callback" => \Cloudinary::option_get($options, "callback"),
|
145 |
"eager" => Uploader::build_eager(\Cloudinary::option_get($options, "eager")),
|
146 |
+
"eager_async" => \Cloudinary::option_get($options, "eager_async"),
|
147 |
+
"eager_notification_url" => \Cloudinary::option_get($options, "eager_notification_url"),
|
148 |
"headers" => Uploader::build_custom_headers(\Cloudinary::option_get($options, "headers")),
|
149 |
"tags" => \Cloudinary::encode_array(\Cloudinary::option_get($options, "tags")),
|
150 |
"face_coordinates" => \Cloudinary::encode_double_array(\Cloudinary::option_get($options, "face_coordinates")),
|
252 |
|
253 |
$post_params = array();
|
254 |
if ($file) {
|
255 |
+
if (!preg_match('/^@|^ftp:|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/', $file)) {
|
256 |
if (function_exists("curl_file_create")) {
|
257 |
$post_params['file'] = curl_file_create($file);
|
258 |
$post_params['file']->setPostFilename($file);
|
265 |
}
|
266 |
|
267 |
curl_setopt($ch, CURLOPT_POST, true);
|
268 |
+
$timeout = \Cloudinary::option_get($options, "timeout", \Cloudinary::config_get("timeout", 60));
|
269 |
+
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout * 1000);
|
270 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
|
271 |
curl_setopt($ch, CURLOPT_CAINFO,realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR."cacert.pem");
|
272 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
273 |
+
curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::userAgent());
|
274 |
curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
|
275 |
+
|
276 |
+
$range = \Cloudinary::option_get($options, "content_range");
|
277 |
+
if ($range != NULL){
|
278 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Range: '.$range));
|
279 |
+
}
|
280 |
+
\Mage::log(\Cloudinary::userAgent());
|
281 |
$response = curl_exec($ch);
|
282 |
$curl_error = NULL;
|
283 |
if(curl_errno($ch))
|
lib/CloudinaryExtension/CloudinaryImageProvider.php
CHANGED
@@ -50,6 +50,7 @@ class CloudinaryImageProvider implements ImageProvider
|
|
50 |
private function authorise()
|
51 |
{
|
52 |
Cloudinary::config($this->configuration->build());
|
|
|
53 |
}
|
54 |
|
55 |
private function getSignedValidationUrl()
|
50 |
private function authorise()
|
51 |
{
|
52 |
Cloudinary::config($this->configuration->build());
|
53 |
+
Cloudinary::$USER_PLATFORM = $this->configuration->getUserPlatform();
|
54 |
}
|
55 |
|
56 |
private function getSignedValidationUrl()
|
lib/CloudinaryExtension/Configuration.php
CHANGED
@@ -15,6 +15,8 @@ class Configuration
|
|
15 |
|
16 |
private $cdnSubdomain = true;
|
17 |
|
|
|
|
|
18 |
private function __construct(Cloud $cloud,Credentials $credentials)
|
19 |
{
|
20 |
$this->cdnSubdomain = false;
|
@@ -76,4 +78,20 @@ class Configuration
|
|
76 |
"api_secret" => (string)$this->credentials->getSecret()
|
77 |
);
|
78 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
15 |
|
16 |
private $cdnSubdomain = true;
|
17 |
|
18 |
+
private $userPlatform = '';
|
19 |
+
|
20 |
private function __construct(Cloud $cloud,Credentials $credentials)
|
21 |
{
|
22 |
$this->cdnSubdomain = false;
|
78 |
"api_secret" => (string)$this->credentials->getSecret()
|
79 |
);
|
80 |
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getUserPlatform()
|
86 |
+
{
|
87 |
+
return $this->userPlatform;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @param string $userPlatform
|
92 |
+
*/
|
93 |
+
public function setUserPlatform($userPlatform)
|
94 |
+
{
|
95 |
+
$this->userPlatform = $userPlatform;
|
96 |
+
}
|
97 |
}
|
lib/CloudinaryExtension/Image/Transformation/Dimensions.php
CHANGED
@@ -10,8 +10,8 @@ class Dimensions
|
|
10 |
|
11 |
private function __construct($width, $height)
|
12 |
{
|
13 |
-
$this->width = $width;
|
14 |
-
$this->height = $height;
|
15 |
}
|
16 |
|
17 |
public function getWidth()
|
10 |
|
11 |
private function __construct($width, $height)
|
12 |
{
|
13 |
+
$this->width = is_null($width) ? null : (int) round($width);
|
14 |
+
$this->height = is_null($height) ? null : (int) round($height);
|
15 |
}
|
16 |
|
17 |
public function getWidth()
|
package.xml
CHANGED
@@ -1,27 +1,21 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cloudinary_Cloudinary</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT License (MITL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Cloudinary - Image Management In The Cloud</summary>
|
10 |
<description>Cloudinary supercharges your images! Upload images to the cloud, deliver optimized via a fast CDN, perform smart resizing and apply effects.</description>
|
11 |
-
<notes>v1.
|
12 |

|
13 |
-
|
14 |
-
|
15 |
-
* Dynamic manipulation of Magento product images to match your graphic design and theme.
|
16 |
-
* Smart image optimization for faster page loading, better user experience and reduced bandwidth costs.
|
17 |
-
* Optimized fast CDN delivery of your media files to all worldwide visitors of your site.
|
18 |
-
* Automatic product images upload and migration to the cloud.
|
19 |
-
* Access to interactive media library web interface.
|
20 |
-
</notes>
|
21 |
<authors><author><name>Cloudinary</name><user>cloudinary</user><email>accounts+magento@cloudinary.com</email></author></authors>
|
22 |
-
<date>2015-
|
23 |
-
<time>
|
24 |
-
<contents><target name="magecommunity"><dir name="Cloudinary"><dir name="Cloudinary"><dir name="Block"><dir name="Adminhtml"><dir name="Manage"><file name="Grid.php" hash="b6a05f6ba08c5ba0d08846a7b0a06776"/></dir><file name="Manage.php" hash="0e5969a1fb7ce270776c3c80fb07a072"/><dir name="Page"><file name="Menu.php" hash="891d6a4c075ba03c9a20658076c86ad0"/></dir><dir name="System"><dir name="Config"><file name="Signup.php" hash="235c27f236e45900eb94dea0181027cc"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CloudinaryController.php" hash="e14ba0c37dafefca8347783b3616403c"/></dir></dir><dir name="data"><dir name="cloudinary_setup"><file name="data-upgrade-0.1.0-0.1.1.php" hash="4c6ce6cd9ab0d94654afb4a398fb3d6c"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="46e365e2f4b1d543aad248dfcfb99c50"/><file name="config.xml" hash="
|
25 |
<compatible/>
|
26 |
<dependencies><required><php><min>5.4.0</min><max>7.0.0</max></php></required></dependencies>
|
27 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cloudinary_Cloudinary</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT License (MITL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Cloudinary - Image Management In The Cloud</summary>
|
10 |
<description>Cloudinary supercharges your images! Upload images to the cloud, deliver optimized via a fast CDN, perform smart resizing and apply effects.</description>
|
11 |
+
<notes>v1.1.0
|
12 |

|
13 |
+
* Fix bug when image sizes contain a decimal point
|
14 |
+
* Update to latest Cloudinary PHP Library</notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
<authors><author><name>Cloudinary</name><user>cloudinary</user><email>accounts+magento@cloudinary.com</email></author></authors>
|
16 |
+
<date>2015-06-08</date>
|
17 |
+
<time>13:05:01</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Cloudinary"><dir name="Cloudinary"><dir name="Block"><dir name="Adminhtml"><dir name="Manage"><file name="Grid.php" hash="b6a05f6ba08c5ba0d08846a7b0a06776"/></dir><file name="Manage.php" hash="0e5969a1fb7ce270776c3c80fb07a072"/><dir name="Page"><file name="Menu.php" hash="891d6a4c075ba03c9a20658076c86ad0"/></dir><dir name="System"><dir name="Config"><file name="Signup.php" hash="235c27f236e45900eb94dea0181027cc"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CloudinaryController.php" hash="e14ba0c37dafefca8347783b3616403c"/></dir></dir><dir name="data"><dir name="cloudinary_setup"><file name="data-upgrade-0.1.0-0.1.1.php" hash="4c6ce6cd9ab0d94654afb4a398fb3d6c"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="46e365e2f4b1d543aad248dfcfb99c50"/><file name="config.xml" hash="76e9a03863c9599d13adcb2d2a834778"/><file name="system.xml" hash="ea40bfc4a7ef533b1800d49c70bc3706"/></dir><dir name="Helper"><file name="Autoloader.php" hash="393b3e2fc25e63ca28157152d2542b18"/><dir name="Configuration"><file name="Validation.php" hash="6d17d39ba39f67888701fadf0fe3de62"/></dir><file name="Configuration.php" hash="a5c02c7b02a0c263d9f6b8f58b08e746"/><file name="Console.php" hash="e4ca7f9bf450b05383def130b2819ce0"/><file name="Data.php" hash="42c9d44f1bbe530e30cf5379846dea65"/><file name="Image.php" hash="018d99d47230d570c40e4c4dabcdfa2f"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><file name="Image.php" hash="3634cce83bfa42768f7dbbc2958bbe9a"/><dir name="Media"><file name="Config.php" hash="678422f87913a2ea70ec717aaa2169b1"/></dir><file name="Media.php" hash="4804b00885bfe279ee43a1b290d801da"/></dir></dir><dir name="Cms"><dir name="Adminhtml"><dir name="Template"><file name="Filter.php" hash="4ef453061d790fff6b772286e90439f2"/></dir></dir><file name="Synchronisation.php" hash="c62e3ed78d7463267951157d6ff8bdc9"/><dir name="Template"><file name="Filter.php" hash="5ec9589ef22b1e9c88b20c3272d01f8c"/></dir><file name="Uploader.php" hash="bcaca2303cf806d41bac82a009ba9eb6"/><dir name="Wysiwyg"><dir name="Images"><file name="Storage.php" hash="b3eae9a3a4810d9de5ab6a91243d047d"/></dir></dir></dir><file name="Cron.php" hash="a02414ee2fca1b1e65cb9c5fa59ee657"/><dir name="Exception"><file name="BadFilePathException.php" hash="68135da8dfe2f0589a531b4bd36e3330"/></dir><file name="Image.php" hash="4a2ee22c0ca6510b7633ef2ef3541587"/><file name="Logger.php" hash="c497bae551881533afbb08882f73e91d"/><file name="MediaCollectionCounter.php" hash="a7772d711b6d5fcdde2fa042fc1f7b1d"/><file name="Migration.php" hash="e923053b36d2ab469362b3590935ecfe"/><file name="Observer.php" hash="22a8e380ac895894f218e7239560b2e2"/><file name="PreConditionsValidator.php" hash="8f5f33e3b8c7755d80ae5036848dd5ff"/><dir name="Resource"><dir name="Cms"><dir name="Synchronisation"><file name="Collection.php" hash="94108abee4e5e4a0a7534bfbb7f7e85b"/></dir></dir><dir name="Media"><file name="Collection.php" hash="1805b96c4ad84aa72862b605054ecdfb"/></dir><file name="Migration.php" hash="69a545d0627016afc03ea097641aa749"/><dir name="Synchronisation"><file name="Collection.php" hash="04fe388bb68b38248922884f80126e80"/></dir><file name="Synchronisation.php" hash="5b721d854d8f89bc3310e46081be7153"/></dir><file name="Synchronisation.php" hash="53de366c8e304c5c0a823df1095a276c"/><file name="SynchronisedMediaUnifier.php" hash="7cd30f02d4877caff089230809699b0f"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Dpr.php" hash="2b9bfd5f836dbdb5d7224d298264f540"/><file name="Gravity.php" hash="c241498e2093640892170673cd7550cd"/><file name="Quality.php" hash="e0c5902f5c36c96fb8a8ba7cc741ce1f"/></dir></dir></dir></dir></dir><dir name="sql"><dir name="cloudinary_setup"><file name="install-0.1.0.php" hash="55d93b3dab573c2a932edbb5a2fa4865"/><file name="upgrade-0.1.0-0.1.1.php" hash="6c8d430fbf7b9714586b67db3d455008"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cloudinary_Cloudinary.xml" hash="9337962a4ccf8a43164d5d71dfd2d756"/></dir></target><target name="magelib"><dir name="CloudinaryExtension"><file name="CloudinaryImageProvider.php" hash="4142e17a23c4a36380a8efeae504cf0c"/><file name="Cloud.php" hash="59b0debf9ae297e4e824e39ba819b1d1"/><file name="Configuration.php" hash="b4ece3c87e2aa2af83b8362311ad7850"/><file name="Credentials.php" hash="ccd2da6450df39f3218cfd64ac47103f"/><dir name="Exception"><file name="InvalidCredentials.php" hash="abecc635a25f6c9896c605ad16e1f7d7"/></dir><dir name="Image"><file name="Synchronizable.php" hash="dffcdc40ed5a5cde556ef200d3c544ba"/><dir name="Transformation"><file name="Dimensions.php" hash="8b9a09da6980aa2ff42e8f00d79a1b83"/><file name="Dpr.php" hash="f78cd1bfabaf3088ca8d4af972bfd453"/><file name="FetchFormat.php" hash="b81c62dd756dee4ad085ee6f0a83356a"/><file name="Format.php" hash="ab8ea9b6a8c813a24f23b079ea6236da"/><file name="Gravity.php" hash="c1c2adf4dbbeaa6b06d67d2014300559"/><file name="Quality.php" hash="23a857f3910aecf6e45645194ff7f54e"/></dir><file name="Transformation.php" hash="fc443a6abad4a478e94df5661e4aef12"/></dir><file name="Image.php" hash="ea59732b244899cb5b69b3e3e86cffee"/><file name="ImageProvider.php" hash="f4eb49d5e1e4c1728a5dde29b6b5a3fa"/><dir name="Migration"><file name="BatchUploader.php" hash="7cd66596475070673e2467506a9b86ed"/><file name="Logger.php" hash="69f5416f6a3176907b40fce72c2d6e23"/><file name="Queue.php" hash="add92864192b0950c29c91ffe5e5a3ee"/><file name="SynchronizedMediaRepository.php" hash="9e7e1dae66b40ce991b0e86ecdff4c24"/><file name="Task.php" hash="ac11d06c531d48b38cf88f6e8f2bdc19"/></dir><dir name="Security"><file name="ApiSignature.php" hash="049c7db2684ec2a6cf5bb4efcd064951"/><file name="CloudinaryEnvironmentVariable.php" hash="2b5c28381b52350586ea1589854ca498"/><file name="ConsoleUrl.php" hash="4e748cfe0f5a0aeab2307c623179c6f9"/><file name="EnvironmentVariable.php" hash="297fa60b819ffc028b9a32dae6eef63d"/><file name="Key.php" hash="ac3a50b59f2a7db1edcf30386759c7ec"/><file name="Secret.php" hash="b1010679976575d57752dbb07f1b94ed"/><file name="SignedConsoleUrl.php" hash="791e1f1080be23423c2ad87f431f6221"/></dir><file name="ValidateRemoteUrlRequest.php" hash="c2e2eb712e5293ad508a23610dfbbd6d"/></dir><dir name="Cloudinary"><file name="Api.php" hash="972fbd112fdf3745b5c1efa457e71a7f"/><file name="cacert.pem" hash="c4290b9deb70d0bef2f88b67fc68c8ec"/><file name="CloudinaryField.php" hash="411714580d21b58115ab07737367173a"/><file name="Cloudinary.php" hash="1e3709faea6e006fa09c0d1fc2052836"/><file name="Helpers.php" hash="63035ebeaa237bd69dcad2d756a00b44"/><file name="PreloadedFile.php" hash="73cc9e276f96553814f05eae592d11ee"/><file name="Uploader.php" hash="0d62ad1f0816fbb5d1dddd30bdf3f082"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="cloudinary"><file name="cloudinary.xml" hash="8cf333ec4b49c684ea6a209061f5128b"/></dir></dir><dir name="template"><dir name="cloudinary"><file name="manage.phtml" hash="c5a74ed0528f36b409039d5fbdeb8cb9"/><dir name="system"><dir name="config"><file name="signup.phtml" hash="2a0e06990eb542f22531ac2ebb5996f5"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.4.0</min><max>7.0.0</max></php></required></dependencies>
|
21 |
</package>
|