Skip to content

Commit

Permalink
Merge pull request #34 from cloudinary/v2.8.4
Browse files Browse the repository at this point in the history
V2.8.4
  • Loading branch information
Pini authored Dec 5, 2018
2 parents dd9afc0 + da9829a commit 9dba349
Show file tree
Hide file tree
Showing 220 changed files with 7,047 additions and 4,662 deletions.
7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2018 Cloudinary

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 25 additions & 5 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# Cloudinary Magento Extensions
# Magento 1 [Cloudinary](https://www.cloudinary.com/) Module

This repository contains packages to support Cloudinary on Magento platforms.
Magento 1 module for integration with Cloudinary.

- Magento 1 Cloudinary module
- Magento 2 Cloudinary module
- Shared core library used by both Magento modules.
---

## Install Manually
1. Download & copy/drag the directories `app`, `lib` & `skin` into your Magento 1 root dir.
2. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.

## Install Using Modman
1. If you don't have modman installed, install it first according to the [official instructions](https://github.com/colinmollenhour/modman#installation) & then follow the [instructions for Magento users](https://github.com/colinmollenhour/modman#magento-users).
2. cd into your Magento 1 root dir & run `modman init` (in case you haven't done it already).
3. Under your Magento 1 root dir, run `modman clone Cloudinary_Cloudinary https://github.com/cloudinary/cloudinary_magento`
4. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.

## Update Using Modman
1. Under your Magento 1 root dir, run `modman update Cloudinary_Cloudinary`
2. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.

---

https://www.cloudinary.com/

Copyright © 2018 Cloudinary. All rights reserved.

![Cloudinary Logo](https://cloudinary-res.cloudinary.com/image/upload/c_scale,w_300/v1/logo/for_white_bg/cloudinary_logo_for_white_bg.svg)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Wysiwyg Images Helper - Override for Mage_Cms_Helper_Wysiwyg_Images
*/
class Cloudinary_Cloudinary_Helper_Cms_Wysiwyg_Images extends Mage_Cms_Helper_Wysiwyg_Images
{

/**
* Images Storage root directory
* Overrided in order to prevent realpath() when the media dir is a symlink
*
* @return string
*/
public function getStorageRoot()
{
if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) {
return parent::getStorageRoot();
}
if (!$this->_storageRoot) {
$this->_storageRoot = Mage::getConfig()->getOptions()->getMediaDir()
. DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY . DS;
}
return $this->_storageRoot;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ public function isEnabled()
return $this->mageCache->canUse(self::CACHE_NAME);
}

public function save($key, $value)
public function saveCache($key, $value)
{
$this->mageCache->save($value, $key, array(self::CACHE_TAG));
}

public function load($key, callable $uncachedCall = null)
public function loadCache($key, callable $uncachedCall = null)
{
$value = $this->isEnabled()
? $this->mageCache->load($key)
: false;

if ($value === false && !is_null($uncachedCall)) {
$value = $uncachedCall();
$this->save($key, $value);
$this->saveCache($key, $value);
}

return $value;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ class Cloudinary_Cloudinary_Model_Configuration implements ConfigurationInterfac
const STATUS_DISABLED = 0;
const USER_PLATFORM_TEMPLATE = 'CloudinaryMagento/%s (Magento %s)';
const CONFIG_PATH_ENVIRONMENT_VARIABLE = 'cloudinary/setup/cloudinary_environment_variable';
//= Configuration
const CONFIG_SMART_SERVING = 'cloudinary/configuration/cloudinary_smart_serving';
const CONFIG_CDN_SUBDOMAIN = 'cloudinary/configuration/cloudinary_cdn_subdomain';
const CONFIG_FOLDERED_MIGRATION = 'cloudinary/configuration/cloudinary_foldered_migration';
//= Transformations
const CONFIG_DEFAULT_GRAVITY = 'cloudinary/transformations/cloudinary_gravity';
const CONFIG_DEFAULT_QUALITY = 'cloudinary/transformations/cloudinary_image_quality';
const CONFIG_DEFAULT_DPR = 'cloudinary/transformations/cloudinary_image_dpr';
const CONFIG_DEFAULT_FETCH_FORMAT = 'cloudinary/transformations/cloudinary_fetch_format';
const CONFIG_CDN_SUBDOMAIN = 'cloudinary/configuration/cloudinary_cdn_subdomain';
const CONFIG_FOLDERED_MIGRATION = 'cloudinary/configuration/cloudinary_foldered_migration';
const CONFIG_GLOBAL_FREEFORM = 'cloudinary/transformations/cloudinary_free_transform_global';
//= Logging
const CONFIG_LOG_ACTIVE = 'cloudinary/log/cloudinary_log_active';
const CONFIG_LOG_FILENAME = 'cloudinary/log/cloudinary_log_filename';
//= Advanced
const CONFIG_PATH_REMOVE_VERSION_NUMBER = 'cloudinary/advanced/remove_version_number';
const CONFIG_PATH_USE_ROOT_PATH = 'cloudinary/advanced/use_root_path';

private $environmentVariable;

Expand Down Expand Up @@ -68,7 +74,7 @@ public function getDefaultTransformation()
->withDpr(Dpr::fromString($this->getImageDpr()))
->withFreeform(Freeform::fromString($this->getDefaultGlobalFreeform()));

if ($this->isSmartServing()){
if ($this->isSmartServing()) {
$transformation
->addFlags(array('lossy'))
->withFetchFormat(FetchFormat::fromString(FetchFormat::FETCH_FORMAT_AUTO))
Expand Down Expand Up @@ -123,7 +129,8 @@ public function disable()
$this->setStoreConfig(self::CONFIG_PATH_ENABLED, self::STATUS_DISABLED);
}

public function getFormatsToPreserve() {
public function getFormatsToPreserve()
{
return array('png', 'webp', 'gif', 'svg');
}

Expand Down Expand Up @@ -229,7 +236,7 @@ private function getFetchFormat()

private function getImageQuality()
{
return Mage::getStoreConfig(self::CONFIG_DEFAULT_QUALITY);
return (string) Mage::getStoreConfig(self::CONFIG_DEFAULT_QUALITY);
}

private function getImageDpr()
Expand All @@ -241,4 +248,19 @@ private function getDefaultGlobalFreeform()
{
return Mage::getStoreConfig(self::CONFIG_GLOBAL_FREEFORM);
}

/**
* @return bool
*/
public function getRemoveVersionNumber()
{
return (bool) Mage::getStoreConfig(self::CONFIG_PATH_REMOVE_VERSION_NUMBER);
}
/**
* @return bool
*/
public function getUseRootPath()
{
return (bool) Mage::getStoreConfig(self::CONFIG_PATH_REMOVE_VERSION_NUMBER);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public function configSave(Varien_Event_Observer $observer)
*/
public function cloudinaryConfigChanged(Varien_Event_Observer $observer)
{
//Clear config cache before mapping
Mage::app()->getCacheInstance()->cleanType("config");
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => "config"));

if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) {
return;
}
Expand Down Expand Up @@ -85,7 +89,7 @@ private function formatConfigData(array $data)
return implode(
', ',
array_map(
function($key, $value) {
function ($key, $value) {
return sprintf('(%s: %s)', $key, $value);
},
array_keys($data),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function getSynchronizationCacheKeyFromImageName($imageName)
*/
private function cachedSynchronizationCheck(Cloudinary_Cloudinary_Model_Cache $cache, $imageName)
{
return $cache->load(
return $cache->loadCache(
$this->getSynchronizationCacheKeyFromImageName($imageName),
function () use ($imageName) {
return $this->synchronizationCheck($imageName) ? '1' : '0';
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class Cloudinary_Cloudinary_Model_System_Config_Source_Dropdown_Quality
public function toOptionArray()
{
return array(
array(
'value' => '',
'label' => 'Magento\'s Default',
),
array(
'value' => '20',
'label' => '20%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function transformationForImage($imageFile)
*/
public function addFreeformTransformationForImage(Transformation $transformation, $imageFile)
{
$transformationString = $this->cache->load(
$transformationString = $this->cache->loadCache(
$this->getTransformCacheKeyFromImageFile($imageFile),
function () use ($imageFile) {
$this->warmTransformationCache();
Expand All @@ -68,14 +68,14 @@ function () use ($imageFile) {
*/
protected function warmTransformationCache()
{
if ($this->cache->isEnabled() && !$this->cache->load(self::TRANSFORM_CACHE_WARM_KEY)) {
if ($this->cache->isEnabled() && !$this->cache->loadCache(self::TRANSFORM_CACHE_WARM_KEY)) {
foreach ($this->getCollection() as $transformation) {
$this->cache->save(
$this->cache->saveCache(
$this->getTransformCacheKeyFromImageFile($transformation->getImageName()),
$transformation->getFreeTransformation()
);
}
$this->cache->save(self::TRANSFORM_CACHE_WARM_KEY, '1');
$this->cache->saveCache(self::TRANSFORM_CACHE_WARM_KEY, '1');
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Cloudinary_Cloudinary>
<version>2.8.2</version>
<version>2.8.4</version>
</Cloudinary_Cloudinary>
</modules>
<global>
Expand Down Expand Up @@ -77,6 +77,11 @@
<image>Cloudinary_Cloudinary_Helper_Image</image>
</rewrite>
</catalog>
<cms>
<rewrite>
<wysiwyg_images>Cloudinary_Cloudinary_Helper_Cms_Wysiwyg_Images</wysiwyg_images>
</rewrite>
</cms>
<cloudinary_cloudinary>
<class>Cloudinary_Cloudinary_Helper</class>
</cloudinary_cloudinary>
Expand Down
Loading

0 comments on commit 9dba349

Please sign in to comment.