3
Random image in Smarty file
Display random image in Smarty template file
//php file
$smarty->assign('random',
array(
'photo1.jpg',
'photo2.jpg',
'photo3.jpg',
'photo4.jpg'
));
//template file
<style>
{literal}
.myImageDiv {
background: url({/literal}{$siteurl}/themes/{$style}/styles/images/{$random.$randomimage}{literal}) no-repeat transparent;
height: 460px;
background-size: cover;
background-position: center;
}
{/literal}
</style>
rated 3 times
(3)
(0)
comments: 0 / hits: 1657
/ 4 years ago, thu, may 25, 17, 01:29:47
More From
» PHP
Comments
There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account