Skip to content

Instantly share code, notes, and snippets.

@ryarwood
Created December 17, 2012 22:13
Show Gist options
  • Save ryarwood/4322815 to your computer and use it in GitHub Desktop.
Save ryarwood/4322815 to your computer and use it in GitHub Desktop.
Random image start
<?php
$imgString = "/images/elements/gallery-{url_title}-";
$imgGallery = range(1, {community-gallery} + 1);
$i = $start = mt_rand(1, {community-gallery});
do {
if ($i != 0) {
echo '<img src="'.$imgString.$i.'.jpg" width="730" height="340" />';
}
$i = ($i + 1) % count($imgGallery);
} while ($i != $start);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment