[Solar-talk] use getimagesize() in a view

Dmytro Konstantinov umka.dk at gmail.com
Mon May 12 10:52:50 CDT 2008


Jeff,

When you do "$this->image('path/to/image.jpg')" you invoke an image  
helper that builds the entire <img ...> tag for you. The helper is  
aware of the location of you public resources therefore "path/to/ 
image.jpg" works ok.

When you do "$image_info = getimagesize('path/to/image.jpg');" you  
invoke a php function with "path/to/image.jpg" as a parameter. PHP  
neither knows nor cares about the location of your public resources,  
but it does expect you to pass the correct path as a parameter. At a  
guess, I would say that the path you are passing doesn't lead to your  
image file. Try if the following works:

	$image_info = getimagesize(Solar::factory('Solar_Uri_Public')- 
 >quick('path/to/image.jpg'));

Also have a look at the manual page for both Solar_Uri_Public and  
Solar_View_Helper_Image (which you invoke when you do "$this- 
 >image('path/to/image.jpg')" in the layout/view.

	http://solarphp.com/class/Solar_Uri_Public
	http://solarphp.com/class/Solar_View_Helper_Image

Hope it helps!

Dmytro


On 12 May 2008, at 16:22, Jeff Surgeson wrote:

> How do I get php's getimagesize() to find a public image file?
>
> I assumed that passing it a path same as I would if I used a Solar  
> image
> helper as in:
>
> echo $this->image('path/to/image.jpg'); it finds this!
> $image_info = getimagesize('path/to/image.jpg'); not this!
>
> If I put image.jpg in my document root then getimagesize() finds it,  
> so I am
> calling the function ok it just cant find the file. I assume this  
> has to do
> with public paths symbolic links etc. I have my directory layout and  
> symbolic
> links done as per standard (/source /include /config etc) which work  
> fine for
> all else.
>
> Do I need to construct a path using Solar_Uri? is so how do I go  
> about it,
> sorry for missing something which is probably so obvious.
>
> -- 
> ...........::::::...........
> Jeff Surgeson / South Africa
> _______________________________________________
> Solar-talk mailing list
> Solar-talk at lists.solarphp.com
> http://mailman-mail3.webfaction.com/listinfo/solar-talk



More information about the Solar-talk mailing list