•  · 12 friends

Default Profile Photo per gender

How can I assign a defualt profile photo for users who do not upload a profile picture? currently, they automatically get a photo with the first letter of their name, but I want to assign default static photo instead.

Also, is it possible to customize the default profile photo based on the user gender? for example I want all male users to have a default photo which is different from the default photo of female users.

0 0 0 0 0 0
  • 84
Replies (5)
  • Hello Scholar !

    You need to set the false condition for this code:

    'bx_if:show_thumb_letter' => array(

                    'condition' => !$bThumbUrl,

                    'content' => array(

                        'size' => $sTemplateSize,

                        'color' => implode(', ', BxDolTemplate::getColorCode($iProfile, 1.0)),

                        'letter' => mb_strtoupper(mb_substr($sTitle, 0, 1))



    and then change the _getUnitThumbUrl method of BxBaseModProfileTemplate class - redeclare it in necessary children.

    0 0 0 0 0 0
    • LeonidS still not very clear to me. Can you help me with a sample code for _getUnitThumbUrl method and the 'condition' => !$bThumbUrl section?

      I can see a few people liking this discussion question and seem interested in your sample code modification.

      0 0 0 0 0 0
      • You may set the condition as false (forever) via this way:

         'condition' => false, 

        the _getUnitThumbUrl method provides the URL of the image URL from the methods like urlThumb etc (see the same class). Each of them contains the case when the image isn't found like no-picture-thumb.png (in the same class). So you need to redeclare this method in the Template class of the necessary module and process if the result of image URL contains the no-picture word then process it with another, according to aData info.

        0 0 0 0 0 0
        • LeonidS it's still challenging

          My current thought is to create SAMPLE PROFILE (for example profile with id=10) on my website and make its profile photo the default photo. So, if the new user does not upload a profile photo, the template will show the profile photo of the SAMPLE PROFILE

          to do this, I only need to set the default value of the $aData variable for _getUnitThumbUrl method to pass the profile id=10

          may be something similar to:

          $sDefaultThumbUrl = $this->_getUnitThumbUrl ($sTemplateSize, $aData=<PROFILE_ID>, false);

          my questions now, how to set the $aData varialbe to include the profile ID of my SAMPLE PROFILE.

          0 0 0 0 0 0
          • Well, then in your case it will look like:

            private function _getUnitThumbUrl($sSize, $aData, $bSubstituteNoImage = true)


            $CNF = &$this->_oConfig->CNF;

                $sMethod = 'url' . bx_gen_method_name(str_replace('ava', 'avatar', $sSize), array('_', '-'));

                $sUrl = '';

                if(method_exists($this, $sMethod))

                    $sUrl = $this->$sMethod($aData, $bSubstituteNoImage);


                    $sUrl = $this->_getUnitThumbUrl($this->_sUnitSizeDefault, $aData, $bSubstituteNoImage);

                if (strpos($sUrl, 'no-picture-') !== false)


                    $aData[$CNF['FIELD_ID']] = 10; // or any other necessary id

                    $sUrl = $this->_getUnitThumbUrl($sSize, $aData, $bSubstituteNoImage);


                return $sUrl;


            0 0 0 0 0 0
            Not logged in users can't 'Comments Post'.

            UNA - Social Media Software Framework