Jump to content

default user avatars by gender


sopranolv
Go to solution Solved by Ch0cu3r,

Recommended Posts

how make default noavatar if male no avatar show default picture noavatar-male.jpg and if female noavatar-female.jpg

 

here is my code

 $row['avatar'] = $row['avatar'] == "default" ? site_url. "/style/images/avatar.png":site_url.$row['avatar'];
    $sizes = array(25, 46, 75, 100);
    foreach($sizes as $size)
    {
      if($row['avatar'] != site_url."/style/images/avatar.png")
      {
        $row['avatar_'.$size.'x'.$size] = str_replace("_$row[id]", "_$row[id]_".$size."x".$size, $row['avatar']);
        $row['avatar_'.$size.'x'.$size] = $row['avatar_'.$size.'x'.$size] . "?".filemtime($_SERVER['DOCUMENT_ROOT'].str_replace(site_url, '', $row['avatar_'.$size.'x'.$size]));
      }
    }
    if($row['avatar'] == site_url."/style/images/avatar.png")
    {
      foreach($sizes as $size)
      {
        $row['avatar_'.$size.'x'.$size] = $row['avatar'];
      }
    }
    else
    {
      $row['avatar'] .= "?".filemtime($_SERVER['DOCUMENT_ROOT'].str_replace(site_url, '', $row['avatar']));
    }
Link to comment
Share on other sites

  • Solution

This line here  is setting the avatar to the default avatar image, if $row['avatar'] is set to the string literal default

$row['avatar'] = $row['avatar'] == "default" ? site_url. "/style/images/avatar.png":site_url.$row['avatar'];

You will need to change that line to something like this

if($row['avatar'] == "default")
{
    $row['avatar'] = site_url. "/style/images/noavatar-".$yourGenderVariableHere.".png";
}
else
{
    $row['avatar'] = site_url.$row['avatar'];
}

Replace  $yourGenderVariableHere  with your variable that contains the users gender.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.