When a picture is displayed in user profile its source code looks like this
<img src="//localhost/drupal/files/pictures/picture-44.png" alt="Someones picture" title="Someones picture" />
This is caused by theme_image function in theme.inc on line 540:
return '<img src="'. check_url(base_path() . $path) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
The problem is that $path is already a full url to which base_path is appended which then looks sth like this
/drupal/http://localhost/drupal/files/pictures/picture-44.png
And then check_url strips this url into that which is later displayed.
I think this could be solved in two ways:
1. in theme_image function change return to
return '<img src="'. check_url($path) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
2. in theme_user_picture function in user.module on line 653 change this line
$picture = file_create_url($account->picture);
to
$picture = $account->picture;
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | user.image.diff.txt | 951 bytes | beginner |
| #5 | user.module.emtag.patch.txt | 765 bytes | Rok Žlender |
| #2 | theme.inc.patch_1.txt | 929 bytes | Rok Žlender |
| #1 | theme.inc.patch_0.txt | 939 bytes | Rok Žlender |
Comments
Comment #1
Rok Žlender commentedI wrote a short patch which changes theme.inc theme_image function please have a look.
Comment #2
Rok Žlender commentedQuick update maybe it would be better to use file_create_url function.
Comment #3
beginner commentedComment #4
beginner commentedpatch needs to be updated for head.
When I tested, I had an url like:
<img src="http://127.0.0.1/73087-cvs/files/pictures/picture-1.jpg" alt="<em>test</em>'s picture" title="<em>test</em>'s picture" />Two problems:
1- src is wrong: the image is at: /pictures/picture-1.jpg NOT at /files/pictures/picture-1.jpg.
2-
<em></em>was check_plain'ed and the tags were hardcoded and presented as is on the screen.Comment #5
Rok Žlender commented1. The recent changes in core http://drupal.org/node/59912 fixes this problem for me. How doid you set your picture folder so it is not in files dir
2. attached patch cleans $alt off all html tags this fixes tag problem
Comment #6
beginner commentedthe url problem what due to a mistake I made.
The patch is what I believe is the proper fix. (user @user placeholder instead of %user).
Comment #7
Rok Žlender commentedBeginners patch works for me.
Comment #8
dries commentedCommitted to CVS HEAD. Thanks folks. Rock on. :)
Comment #9
dries commentedComment #10
(not verified) commented