generate random width of img
hi, im using this code that displays X amount of images from a facebook page. the width and height is preset. Id like to generate the width for each image, so that all images would have different sizes when they are displayed.
Id also like to set a max width and a min width, so no images are larger than 200px and smaller than 40px, so they can be in any size between 40 and 200 px.
<?php foreach($photos as $photo): ?>
<div class="thumbnail" style="height: <?php echo $size ?>px; width: <?php echo $size ?>px">
<img src="<?php echo $photo['src'] ?>" alt="<?php echo htmlentities($photo['caption'], ENT_QUOTES) ?>" />
<?php endforeach; ?>
I guess you could just use rand();
$min = 40;
$max = 200;
$width = rand($min,$max);
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread