• 把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;
    }
  • 相关阅读:
    Apache基本设置
    主流无线传输技术GPRS与CDMA之对比
    光波分复用系统(WDM)技术要求
    IPv6报头结构以及与IPv4的比较
    网络设计师训练资料
    802.11b/11a/11g横向比较
    交换机术语
    无线局域网技术白皮书
    无线网络基础知识
    校验码
  • 原文地址:https://www.cnblogs.com/dongtong/p/5870786.html
Copyright © 2020-2023  润新知