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;
    }
  • 相关阅读:
    luogu P2015 二叉苹果树
    luogu P1197 [JSOI2008]星球大战
    QBXT T15214 Day2上午遭遇
    luogu P2831 愤怒的小鸟
    luogu P1018 乘积最大
    [BZOJ2402]陶陶的难题II(树链剖分+线段树维护凸包+分数规划)
    [BZOJ1500][NOI2005]维修数列(splay)
    [BZOJ3282]Tree(LCT)
    [BZOJ4785][ZJOI2017]树状数组(概率+二维线段树)
    [BZOJ2427][HAOI2010]软件安装(Tarjan+DP)
  • 原文地址:https://www.cnblogs.com/dongtong/p/5870786.html
Copyright © 2011-2022 走看看