How to randomly call multiple thumbnails of dedecms dream weaving

The dream weaving dedecms article list can call the pictures in the article as thumbnails. If there is no thumbnail in the article, the default thumbnail of the dream weaving will be called.

The default thumbnail of Dream Weaving is not beautiful, we usually have two ways to replace the default thumbnail.
 
Method 1:
Directly replace the picture of the default thumbnail. This picture is located in the root directory/images/defaultpic.gif. We only need to replace this picture with another picture.
 
 
Method 2:
Although the above method replaces the default thumbnail, if the same default thumbnail is displayed in the article, it is not beautiful. We have another method to set multiple default thumbnails. When the article does not have thumbnails, just The thumbnails of the selected area will be randomly selected among the multiple default thumbnails. The method is as follows:
 
1. Add the following code in /include/extend.func.php (be careful not to copy and paste it into an existing function):
 
$gocweb_RandPicArr=array(
    //The following is a list of your random pictures, yes Just add a few of them, and there can be no commas after the last one","
    '/ images/randpic1.jpg
    ',
    '/ images/randpic2.jpg ', '/ images/randpic3.jpg '
);
 
function gcGetRandLitpic($pic)
{     if(substr($pic,-22)=='/images/defaultpic.gif')     {         global $gocweb_RandPicArr;



        $pic = $gocweb_RandPicArr[mt_rand(0,count($gocweb_RandPicArr)-1)];
    }
    return $pic;
}
 
 
2. Call at the place where the thumbnail tag of the list is called:

<img src="[field:litpic function='gcGetRandLitpic(@me)'/]" />

Method three:

Replace the picture address directly.

Guess you like

Origin blog.csdn.net/qq_39339179/article/details/109817477