把magento所见即所得默认生成的图片缓存路径改为图片真实路径

From:

/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvd2lkZ2V0cy9iYW5uZXIvaG9tZXBhZ2UvZm9yZWdyb3VuZC9maXNoLXRhbmsucG5nIn19/key/e8167e3884e40b97d8985e7b84e7cbc7875f134e5f7e5946c9c2a482d0279762/

To:

/media/wysiwyg/path/to/file/photo.jpg

 

1、 Adding a new GET parameter use_file_url to the URL

$url    = $this->getUrl( '*/cms_wysiwyg_images/index', array( 'target_element_id' => $element->getName(), 'use_file_url' => 1 ) );

2、Override the getOnInsertUrl() function of the Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content:

public function getOnInsertUrl() { $useFileUrl = (int)$this->getRequest()->getParam('use_file_url', 0); return $this->getUrl('*/*/onInsert', array('use_file_url' => $useFileUrl)); }

3、Handle the new parameter in the Mage_Adminhtml_Cms_Wysiwyg_ImagesControllercontroller:

public function onInsertAction() { $useFileUrl = (int)$this->getRequest()->getParam('use_file_url', 0) == 1 ? true : false; $helper = Mage::helper('cms/wysiwyg_images'); $storeId = $this->getRequest()->getParam('store'); $filename = $this->getRequest()->getParam('filename'); $filename = $helper->idDecode($filename); $asIs = $this->getRequest()->getParam('as_is'); Mage::helper('catalog')->setStoreId($storeId); $helper->setStoreId($storeId); if ($useFileUrl == false) { $image = $helper->getImageHtmlDeclaration($filename, $asIs); } else { $image = $helper->getImageMediaUrl($filename); } $this->getResponse()->setBody($image); }

4、Override the Mage_Cms_Helper_Wysiwyg_Images helper and add the getImageMediaUrl() function:

public function getImageMediaUrl($filename) { return $this->getCurrentUrl() . $filename; }

转载于:https://www.cnblogs.com/dongtong/p/5870786.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值