I want test my first self-employed magento modules on a magento shop. I created a ubuntu server, configured local.xml and base_url but now I need a solution for the big media folder from livesystem.

At the moment I don't want to change product images or something else - already want to test an extension with a few layout updates in a realistic situation.

Routing media urls to live system host name don't work. I think magento check also if the file exists local and CDN typical get established via simple virtual host generally.

So setting CDN to external host doesn't work, I tried to configure a placeholder image via admin backend but when I delete cache and reload the function:


<img class="img-responsive" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(false)->keepAspectRatio(true)->keepFrame(true)->resize($_image_resize_width,$_image_resize_height); ?>"

Seems to doesn't work. If I show in quellcode it ends on the first product image with

<img class="img-responsive" src="

without footer etc.

Anybody have an idea whats the simplest solution in this case? My preffered solution would be, that magento simple use the external url from livesystem for media images. But when I show in the Image Model/Helper the local filesystem path for images seems deeply anchored in system.


  • Have you try to change media url from config -> web Nov 18, 2016 at 5:05
  • Thanks for answer! As described in top I also tried to edit CDN (config->web) to external server url and upload placeholder images - the $this->helper('catalog/image')->init... helper seem not working correct. I debugged the function and see, that the placeholder path build correct - but on the frist product on category page, the quellcode in frontend ends with <img class="img-responsive" src=" - no footer or closing blocks. So the site on testsystem isn't usable. The helper function return an object, but the class contains an __toString() function that might issued on "echo" I thought.
    – Mike
    Nov 18, 2016 at 8:52

1 Answer 1


If you're running Apache, this should get you there – at least it works for me:

RewriteCond %{HTTP_HOST} your.local.domain$ [NC]
RewriteRule ^media/(.*)$ http://your.live.domain/media/$1 [N,L]

This however requires identical cached image paths existing on both sites for images in question. To cope with that, you could test with non-cached original files. In app/code/core/Mage/Catalog/Helper/Image.php, make __toString() the following:

public function __toString()
        str_replace(DS, '/', $this->_product->getData($this->_model->getDestinationSubdir()));

You can even skip Apache rewriting by replacing Mage::getBaseUrl('media') with 'http://your.live.domain/media/'.

Bear in mind, though, that this will get you full resolution images over the wire which may be totally acceptable for testing, but you might have to set image dimensions by html or css.

To at least make thumbnails work, you should first check for your Magento logs possibly indicating what's wrong inside the init() and subsequent calls, and after doing so test for file system permissions: make sure your webserver has write access to media folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.