Created
June 24, 2013 16:39
-
-
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]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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] ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[1] - http://wordpress.org/plugins/nextgen-gallery/
[2] - https://github.com/srobbin/jquery-backstretch