Variable $alt not set correctly

smitty - November 27, 2008 - 09:53
Project:ImageCache Profiles
Version:5.x-1.4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

The variable $alt is set in line 43 of the imagecache_profiles.module. But this means, that it is set only if the user has uploaded an own user-picture. If he hasn't and is using the default picture, the variable $alt is not set. Nonetheless it is used in lines 53 and 54.

My proposal is to take line 43 in front of line 42 and so to change the lines 42-56 from

    if ($account->picture && file_exists($account->picture)) {
      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
      if (isset($size)) {
        $picture = theme('imagecache', $size, $account->picture, $alt, $alt);
      } else {
        $picture = theme('image', file_create_url($account->picture), $alt, $alt, '', FALSE);
      }
    } else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
      if (isset($size)) {
        $picture = theme('imagecache', $size, $picture, $alt, $alt);
      } else {
        $picture = theme('image', file_create_url($picture), $alt, $alt, '', FALSE);
      }
    }

to

    $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));   
    if ($account->picture && file_exists($account->picture)) {
      if (isset($size)) {
        $picture = theme('imagecache', $size, $account->picture, $alt, $alt);
      } else {
        $picture = theme('image', file_create_url($account->picture), $alt, $alt, '', FALSE);
      }
    } else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
      if (isset($size)) {
        $picture = theme('imagecache', $size, $picture, $alt, $alt);
      } else {
        $picture = theme('image', file_create_url($picture), $alt, $alt, '', FALSE);
      }
    }

#1

andypost - September 20, 2009 - 21:25
Status:needs review» needs work

Please provide patch

 
 

Drupal is a registered trademark of Dries Buytaert.