Is there anyway to set a global image setting, route, or anything so that all images reference a CDN url without having to update every image? So when I use the HTML helper like this:
$this->Html->img('some_image.jpg');
Instead of referencing /img/some_image.jpg, it will point to:
http://cdn.example.com/img/some_image.jpg
UPDATE
Final solution was simple. Thanks @burzum for the push in the proper direction. Here is what I did.
In AppController I added:
public $helpers = array(
'Html' => array(
'className' => 'MyHtml'
)
);
Then I created the override helper:
<?php
// app/View/Helper/MyHtmlHelper.php
App::uses('HtmlHelper', 'View/Helper');
class MyHtmlHelper extends HtmlHelper {
// Add your code to override the core HtmlHelper
public function image($path, $options = array()) {
$path = 'http://cdn.localhost/'.$path;
return parent::image($path, $options);
}
}
Simply overwrite the image() method in a customized helper extending the HtmlHelper and use the 2.1 aliasing feature for helpers: