[REPAIRED] header images were less relevant and more clutter...

Nishant Arora 12/Oct/2011
Facebook
Twitter
LinkedIn
Reddit

if you would have noticed that there is a header image section on the top of my website which only displays images from my facebook albums, Now when I imported pics from facebook using plugin called fotobook, I hacked it to display images in a jquery slider (thanks to dynamicdrive), ultimately what happened initially was that at random I was diplaying any pic from the database  wp_fb_photos which had a caption, but lately that was showing more irrelevant stuff than pics I wanted, all thanks to stupid apps and image sharing that tagged me on facebook so they were too pulled in, luckily, fotobook has an option to show/hide particular albums, in which it stores 'aids' (albumids) related with 0= not hidden and 1= hidden, in a separate table wp_fb_albums

so I simply first select the visible albums:

SELECT aid FROM `wp_fb_albums` WHERE hidden = 0 ORDER BY RAND() LIMIT 0,5

and then display pics at random from those visible albums

SELECT * FROM `wp_fb_photos` WHERE aid IN ($aids) ORDER BY RAND() LIMIT 0,10

The final outcome, we have clutter free images being cycled, the script is much more stable, responsive and efficient

Hope you enjoyed the quick snippet!

Good Night!

Cheers!

PS: the code that generate $aids comes in the final code:

$albums = mysql_query( " SELECT aid FROM `wp_fb_albums` WHERE hidden = 0 ORDER BY RAND() LIMIT 0,5 ");
for($a=0;$a<5;$a++){
    $album[$a] = mysql_result($albums,$a,"aid");;
}
$aids = join(',',$album);
$result = mysql_query( " SELECT * FROM `wp_fb_photos` WHERE aid IN ($aids) ORDER BY RAND() LIMIT 0,10 ");