My favorite plugin for images is NextGEN ( I have already written about it). There was only one small item missing – possibility of displaying random images in the sidebar. Actually such option is offered by plugin author but as a widget and I don’t use them. What to do then?
I have had a closer look at both nggwidget.php (to find out how it works) and nggfunctions.php (to check out how functions are created). Hmm… that looked pretty clean and clear so I decided to give it a try.
From nggwidget.php I’ve copied all lines responsible for display and insert of random and recent images (lines 171 to 272) and pasted them to nggfunctions.php file just above // Global function.
Then in the sidebar I’ve put in the chosen place following function
<?php nggDisplayRandomImages(x,y,z);?>
where x is number of images to display, y = width of thumbnail, z = height of thumb. I had to also change a little nggallery.css (part commented as /* –Sidebar widget–*/ ) to have random images the same style as others and… that’s all.
Works like a charm – I have random image in the sidebar without widget :thumbup_tb: .
UPDATE: Sometimes I do too much ;). Accidently I’ve discovered you can just activate random images widget under plugin tab in your admin panel and then put in the sidebar code I’ve written above…