sopranolv Posted October 12, 2015 Share Posted October 12, 2015 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'])); } Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted October 12, 2015 Solution Share Posted October 12, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.