When the user does not upload their avatar in Discuz, the default avatar is displayed, then you can let this default avatar randomly display, the answer is yes, the implementation is relatively simple, if you are familiar with PHP random function rand ().
First of all to prepare a few of their own default profile picture, the size of big (200*200), Middle (120*120), Small (48*48), which is used in the back.
First, open the installed UC directory avatar.php to find the following code:
$size = In_array ($size, Array (' Big ', ' middle ', ' small '))? $size: ' Middle '; $avatar _url = "Images/noavatar_$size.gif";
Replace with:
$size = In_array ($size, Array (' Big ', ' middle ', ' small '))? $size: ' Middle '; $rand _num = rand (1,5),//using Rand () as a random function $avatar _url = ' images/randuser/'. $size. ' /'. $rand _num. gif ';
PS: $avatar _url This variable is actually the address of the Avatar, after which the assignment contains $size and $rand_num this two variables, $size will be rendered large, medium, small map corresponding big, middle, small, $rand _ Num will randomly display 1-5 of one of these numbers, so it's not hard to imagine that the address of the default avatar image will change randomly. It's easy to understand.
Next we should be based on $avatar_url this variable generated by the change of image address upload the corresponding default avatar picture, yes, here the test $rand_num is 1-5 random numbers, and look at the above path, is in the Image/randuser directory to build big, Middle and small three folders, respectively, upload 5, the size of big (200*200), Middle (120*120), Small (48*48).
The resulting default avatar image address will be as follows: Images/randuser/small/2.gif, this 2.gif may be 3.gif or 5.gif.
Reprinted from: http://www.9its.com/article-35-295-1.html
Discuz Random default Avatar