zoukankan      html  css  js  c++  java
  • 把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;
    }
  • 相关阅读:
    踏实每一个脚印——2019年12月复盘
    修改博客园markdown编辑器代码高亮风格的方法
    Hyperion: Building the Largest In memory Search Tree
    C++11——智能指针
    拷贝控制
    分布式系统常见概念
    extern和static使用
    APUE—UNIX文件系统
    C++的一些细节
    fork和僵尸进程
  • 原文地址:https://www.cnblogs.com/dongtong/p/5870786.html
Copyright © 2011-2022 走看看