Re: [SMARTY] html_image issue

From: Date: Wed, 29 Sep 2004 07:06:27 +0000
Subject: Re: [SMARTY] html_image issue
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11830@lists.php.net to get a copy of this message
On Tue, Sep 28, 2004 at 05:17:45PM -0700, Mike Evans wrote: > Hi, > > I've successfully used html_image quite a bit in the past, but recently > ran into this rather odd problem... I'm trying to pass an absolute path > to an image in my local filesystem... say: > /home/htdocs/mike/chandler2/htdocs/data/tn_test.jpg > with: > {html_image file=" /home/htdocs/mike/chandler2/htdocs/data/tn_test.jpg"} > or: > {html_image file=$path_to_image} > > Nothing's getting displayed, however. So, I dug into the actual > function and found this: > > if (substr($file,0,1) == '/') { > $_image_path = $basedir . $file; > } else { > $_image_path = $file; > } > > That doesn't really make sense to me, as if the first character is an > '/' then we're talking about an absolute path, right? not quite. > And that being the case, why would we prepend the $basedir onto it? because it's an URI not an absolute path. we prepend the DOCUMENT_ROOT to it to translate the URI into a local filepath. > Sure enough, it's actually looking for the image at: > /home/htdocs/home/htdocs/mike/chandler2/htdocs/data/tn_test.jpg > > Is this a bug, or am I just missing something obvious? this is not a bug. it's intendet behaviour. {html_image file="/images/foo.jpg"} will be <img src="/images/foo.jpg"> in the browser but the local filepath on the server would be /home/htdocs/images/foo.jpg. regards messju > Thanks a bunch, > Mike

« previous php.smarty.general (#11830) next »