Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_image using variable for image directory

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Fri Jan 21, 2005 4:51 pm    Post subject: html_image using variable for image directory Reply with quote

Hi,

Several times I thought I found the answer to this question in the forum, but each time the problem was different than the one below:

Code:
{html_image file="$Img_Dir/logo.gif"}


$Img_Dir is equal to "http://alpha/skin/images".

This is the error I receive:

Code:
Notice: Smarty error: html_image: unable to find 'http://alpha/skin/images/logo.gif' in /var/www/html/alpha/Smarty-2.6.6/Smarty.class.php on line 1086


http://alpha/skin/images/logo.gif is indeed the correct path to the image (if I paste it into the browser it works just fine). So it appears that html image is either interpretting the variable after the function has already run or is not liking a full path to image.

Thanks to advance for any help on this one.
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Jan 21, 2005 4:59 pm    Post subject: Reply with quote

html_image "file" parameter is expecting a system filepath relative to basedir (doc_root), not a URL.
Back to top
View user's profile Send private message Visit poster's website
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Fri Jan 21, 2005 5:04 pm    Post subject: Reply with quote

Hi mohrt,

Thanks for the reply. Any ideas for a work around (aside from changing the $Img_Dir value of course)?
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Jan 21, 2005 5:13 pm    Post subject: Reply with quote

Actually I stand corrected, getimagesize() supports URL paths since PHP 4.0.5. So, html_image should be able to take a URL just fine.

My guess is that:

http://alpha/skin/images/logo.gif

Is not working because:

1) "alpha" is not a fully qualified hostname.
2) the image does not exist or isn't readable
3) php_ini: allow_url_fopen is false

Get this working first before messing with smarty and html_image:

[php:1:b87146137f]$logo = file_get_contents('http://alpha/skin/images/logo.gif');[/php:1:b87146137f]
Back to top
View user's profile Send private message Visit poster's website
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Fri Jan 21, 2005 6:17 pm    Post subject: Reply with quote

mohrt,

Looks like it's #1. I can grab the image of a site with a "qualified" domain name.

We work on development servers here and have our hosts file changed, obviously PHP is aware of this set up. Do you know if there's any way to change that (like in the php.ini file or something)?
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jan 22, 2005 12:34 am    Post subject: Re: html_image using variable for image directory Reply with quote

machnhed1 wrote:
http://alpha/skin/images/logo.gif is indeed the correct path to the image (if I paste it into the browser it works just fine). So it appears that html image is either interpretting the variable after the function has already run or is not liking a full path to image.


This makes me think that the browser and the php server are on different boxes which are likely on different segments. The way to fix this is to setup a canonical dns entry for alpha which all the machines will share and use. It is completely outside the realm of Smarty and PHP, as far as I can see.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP