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;

Comments

Rok Žlender’s picture

StatusFileSize
new939 bytes

I wrote a short patch which changes theme.inc theme_image function please have a look.

Rok Žlender’s picture

StatusFileSize
new929 bytes

Quick update maybe it would be better to use file_create_url function.

beginner’s picture

Status: Active » Needs review
beginner’s picture

Status: Needs review » Needs work

patch 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="&lt;em&gt;test&lt;/em&gt;&#039;s picture" title="&lt;em&gt;test&lt;/em&gt;&#039;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.

Rok Žlender’s picture

Status: Needs work » Needs review
StatusFileSize
new765 bytes

1. 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

beginner’s picture

Title: Wrong picutre url on user profile page » hard coded <em> on <img> 'alt' attribute in user profile page.
StatusFileSize
new951 bytes

the 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).

Rok Žlender’s picture

Status: Needs review » Reviewed & tested by the community

Beginners patch works for me.

dries’s picture

Committed to CVS HEAD. Thanks folks. Rock on. :)

dries’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)