diff --git app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php index b106d09..0b6af65 100644 --- app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php +++ app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php @@ -49,6 +49,12 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract */ protected $_storeId = null; + /** + * Images Storage root directory + * @var + */ + protected $_storageRoot; + /** * Set a specified store ID value @@ -68,8 +74,13 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract */ public function getStorageRoot() { - return Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY - . DS; + if (!$this->_storageRoot) { + $this->_storageRoot = realpath( + Mage::getConfig()->getOptions()->getMediaDir() + . DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY + ) . DS; + } + return $this->_storageRoot; } /** @@ -197,7 +208,7 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract public function getCurrentPath() { if (!$this->_currentPath) { - $currentPath = realpath($this->getStorageRoot()); + $currentPath = $this->getStorageRoot(); $node = $this->_getRequest()->getParam($this->getTreeNodeName()); if ($node) { $path = realpath($this->convertIdToPath($node)); @@ -223,7 +234,7 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract public function getCurrentUrl() { if (!$this->_currentUrl) { - $path = str_replace(Mage::getConfig()->getOptions()->getMediaDir(), '', $this->getCurrentPath()); + $path = str_replace(realpath(Mage::getConfig()->getOptions()->getMediaDir()), '', $this->getCurrentPath()); $path = trim($path, DS); $this->_currentUrl = Mage::app()->getStore($this->_storeId)->getBaseUrl('media') . $this->convertPathToUrl($path) . '/'; diff --git app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php index 19b3f45..af58ce3 100644 --- app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php +++ app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php @@ -89,7 +89,7 @@ class Mage_Cms_Model_Wysiwyg_Images_Storage extends Varien_Object foreach ($collection as $key => $value) { $rootChildParts = explode(DIRECTORY_SEPARATOR, substr($value->getFilename(), $storageRootLength)); - if (array_key_exists($rootChildParts[0], $conditions['plain']) + if (array_key_exists(end($rootChildParts), $conditions['plain']) || ($regExp && preg_match($regExp, $value->getFilename()))) { $collection->removeItemByKey($key); }