While trying to pass a full URL to theme_image, it doesn't show any image.
echo theme_image('http://drupal.org/themes/bluebeach/logos/drupal.org.png');

So I looked at theme_image(). It seems !$getsize does not work. So I replaced it with $getsize==TRUE.

Now, theme_image works fine.

my system:
PHP 5.0.5-3
Webserver Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-18 mod_ssl/2.8.22 OpenSSL/0.9.7e mod_perl/1.29

Comments

derhasi’s picture

It's not the !$getsize-thing (sure it had to be $getsize!=TRUE) ... it has something to do with getimagesize, I guess.

derhasi’s picture

Now I found the reason: is_file()! - is_file is not able to work with remote files (full URLS).

so I changed theme_image [line 611 of theme.inc] to:

if (!$getsize || ((url($path) == $path || is_file($path)) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {

Now it works, but remote files can get validated.

bdragon’s picture

Status: Needs review » Closed (won't fix)

bad mojo!
You shouldn't be using theme_image with remote urls, period.

povman’s picture

In that case, the documentation is wrong:
$path Either the path of the image file (relative to base_path()) or a full URL.

stella’s picture

Version: 5.1 » 6.2
Assigned: derhasi » Unassigned
Status: Closed (won't fix) » Active

This is actually a bug. Either the function should accept a full url as the documentation states it can do, or the documentation should be corrected. I'm sure other developers will continue to run into this issue until this is resolved.

As for using theme_image() with remote urls, I'm not. I'm trying to give it the url of a local file - generated using file_create_url(). This is because I've noticed that with private file downloads, theme_image() generates a path to the file that isn't a system path (e.g. it's not http://mydomain.com/system/files/foo.jpg).

Cheers,
Stella

webchick’s picture

Version: 6.2 » 7.x-dev

I can confirm this bug.

webchick’s picture

Title: theme_image does not show absolute path's image » theme_image() does not play nicely with private files
Status: Active » Closed (duplicate)

Ok, technically this was earlier, but #238681: theme_image() not evaluating properly? has a patch. Please review.