Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thx krus for you answer! I've found a nicer way to solve the problem with the cached image URLs. I even had to do this, because your solution overwriting the Widget Model didn't work with Magento 1.7.0.2.</p> <p>So what I have done is adding a new GET parameter <code>use_file_url</code> to the URL used for the Chooser Block:</p> <pre><code>$url = $this-&gt;getUrl( '*/cms_wysiwyg_images/index', array( 'target_element_id' =&gt; $element-&gt;getName(), 'use_file_url' =&gt; 1 ) ); </code></pre> <p>This passes the GET parameter to the media browser. The next step is to pass this parameter to the <code>onInsertAction</code> of the <code>Mage_Adminhtml_Cms_Wysiwyg_ImagesController</code>. Do do this, you have to override the <code>getOnInsertUrl()</code> function of the <code>Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content</code> Block:</p> <pre><code>public function getOnInsertUrl() { $useFileUrl = (int)$this-&gt;getRequest()-&gt;getParam('use_file_url', 0); return $this-&gt;getUrl('*/*/onInsert', array('use_file_url' =&gt; $useFileUrl)); } </code></pre> <p>Then you need to handle the new parameter in the <code>Mage_Adminhtml_Cms_Wysiwyg_ImagesController</code> controller:</p> <pre><code>public function onInsertAction() { $useFileUrl = (int)$this-&gt;getRequest()-&gt;getParam('use_file_url', 0) == 1 ? true : false; $helper = Mage::helper('cms/wysiwyg_images'); $storeId = $this-&gt;getRequest()-&gt;getParam('store'); $filename = $this-&gt;getRequest()-&gt;getParam('filename'); $filename = $helper-&gt;idDecode($filename); $asIs = $this-&gt;getRequest()-&gt;getParam('as_is'); Mage::helper('catalog')-&gt;setStoreId($storeId); $helper-&gt;setStoreId($storeId); if ($useFileUrl == false) { $image = $helper-&gt;getImageHtmlDeclaration($filename, $asIs); } else { $image = $helper-&gt;getImageMediaUrl($filename); } $this-&gt;getResponse()-&gt;setBody($image); } </code></pre> <p>The last step is to override the <code>Mage_Cms_Helper_Wysiwyg_Images</code> helper and add the <code>getImageMediaUrl()</code> function:</p> <pre><code>public function getImageMediaUrl($filename) { return $this-&gt;getCurrentUrl() . $filename; } </code></pre> <p>I think this is a quite pretty approach, even though you have to ovverride 4 classes. But passing a GET parameter seems to be more future safe than parsing the cached URL.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload