php - Zend - changing image URL path for deployment -
the title might confusing i'm not sure myself on how explain this. i'm sure pretty simple solution.
i'm moving static images,css,js s3 - can accessed via
egs:
http://files.xyz.com/images/logo.gif http://files.xyz.com/images/submit_button.gif http://files.xyz.com/style/style.css http://files.xyz.com/js/jquery.js
files.xyz.com cname pointing files.xyz.com.s3.amazonaws.com
now in zend layout , views - i'm accessing these full url egs
<img src="http://files.xyz.com/images/logo.gif"/>
my concern when i'm testing on localhost - dont want data fetched s3 local hard disk
so want this. in application.ini - should able specify
resources.frontcontroller.imageurl = http://localhost
and when i'm deploying - change to
resources.frontcontroller.imageurl = http://files.xyz.com
, access in view <img src="<?php echo $this->imageurl;?>/images/logo.gif"/>
what best approach handling thanks
create view helper
public function imageurl() { $config = zend_registry::get('config'); if($config->s3->enabled){ return $config->s3->rootpath; }else{ return $this->view->baseurl(); } } in appilication.ini
s3.enabled = 1 s3.rootpath = https://xxxxx.s3.amazonaws.com you can call
<img src="<?php echo $this->imageurl();?>/images/logo.gif"/> so can enable/disable s3 easily.
Comments
Post a Comment