tags:

views:

456

answers:

2

I wish to use the $html->image(...) helper function in CakePHP to output images, but I need it to produce an img tag using an absolute rather than relative URL (the resulting HTML will be downloaded and emailed round in a company newsletter). Is this possible?

It's not documented, but I notice from looking at the source code that the image function can take an array as its first argument. It's not entirely clear to me how to get this working though - a naive attempt to do it this way produces image URLs relative to the current page rather than within the webroot/img folder.

+2  A: 

$html->image('http://example.com/path_to_image/image.png') should do the trick.

dhofstet
Wow, that's so simple that's embarassing
andygeers
That should be CakePHP's motto :)
mgroves
+1  A: 

<img src="http://example.com/path_to_image/image.png" alt="" />

sometimes it's better to keep the simplest way

Aziz