I am having a weird problem overriding my default user profile pages in 4.7. When I try to print the user pictures, it looks for them in the wrong location. For example, in 4.6, it correctly found the picture at www.example.com/files/pictures/picture-1.jpg. But now in 4.7, when trying to display on the user profile pages, it thinks the picture is located at www.example.com/user/files/pictures/picture-1.jpg. This problem is specific to my theme, because when I use the default bluemarine theme, the user profiles to not exhibit this problem. Then, I tried taking the bluemarine theme and only copying over my template.php and user_profile.tpl.php files and the problem returned.

I have a template.php file looks like this:

<?php
function phptemplate_user_profile($user, $fields = array()) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
}
?>
<?php
function phptemplate_profile_listing($user, $fields = array()) {
return _phptemplate_callback('profile_listing', array('user' => $user, 'fields' => $fields));
}
?>

And the relevant part of my user_profile.tpl.php file looks like this:

<?php if($user->picture): ?> 
<div class="picture">
	<img src=" <?php print $user->picture; ?> ">
</div>
<?php endif; ?> 

<?php if(!$user->picture): ?> 
<div class="picture">
	<img src=" <?php 
	$picture = variable_get('user_picture_default', ''); 
	print $picture; ?> ">
</div>
<?php endif; ?>

I've been stuck on this problem for hours. Any help is greatly appreciated.

Thanks!

Comments

Tiburón’s picture

Hi potential

Read the handbook about the changes in theming from 4.6 to 4.7.

Converting 4.6 themes to 4.7 | drupal.org
http://drupal.org/node/25297

The reason to your problem is likely that Drupal no longer uses the base html element to set the base URL for the Drupal installation. Instead add base_path() to your code.

Change:

  <img src=" <?php print $user->picture; ?> ">

to:

  <img src=" <?php print base_path() . $user->picture; ?> ">

and similarly for your default picture code.

Regards,

Christian Larsen

potential’s picture

Worked great! Thanks