Skip to content

Instantly share code, notes, and snippets.

@bcullen
Created June 24, 2013 16:39
Show Gist options
  • Save bcullen/5851482 to your computer and use it in GitHub Desktop.
Save bcullen/5851482 to your computer and use it in GitHub Desktop.
Pull image URL from gallery (ID = 1) created in NextGEN wordpress plugin [1], randomize & use as fullscreen background with jquery backstretch plugin [2]
$(document).ready(function() {
var bg = [
<?php
global $nggdb;
$gallery = $nggdb->get_gallery(1, 'sortorder', 'ASC', true, 0, 0);
foreach($gallery as $image) {
echo '"'.$image->imageURL.'",';
}
?>
];
var rdm = Math.floor(bg.length * Math.random());
$.backstretch( bg[rdm] );
});
@bcullen
Copy link
Author

bcullen commented Jun 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment