Sep 28
NextGEN Polaroid Plugin Test
The NextGEN Gallery plugin for wordpress is pretty useful, and it there are all sorts of plugins which extend its capabilities. I’ve used the XML Google Maps plugin for example to show photos in NextGEN albums on google maps. There’s also the NextGEN Polaroid plugin which makes the cool flash animation shown below. However, over the course of upgrading Wordpress and the NextGEN gallery to the latest versions, the functionality broke. Here’s how to get it to work with the latest versions (assumes you’ve already downloaded, installed, and tested your NextGEN gallery plugin, and that you’ve already downloaded and installed the NextGEN Polaroid plugin from here):
- First, edit the nggpolaroid.php file line 41 so that it checks for class nggLoader instead of class nggallery. It should look like this:
if ( class_exists('nggLoader') ) {
- Next, copy the code shown below (originally found here) and replace the nggShowPolaroid function with it in the same nggpolaroid.php file. Don’t for get to leave the “?>” at the end of the file.
function nggShowPolaroid($galleryID,$irWidth,$irHeight) { global $wpdb; $ngg_options = get_option('ngg_options'); $obj = 'so' . $galleryID; if (empty($irWidth) ) $irWidth = $ngg_options['irWidth']; if (empty($irHeight)) $irHeight = $ngg_options['irHeight']; $replace = "\n".'<div class="polaroid" id="ngg_polaroid'.$galleryID.'">'; $replace .= 'The <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> and <a href="http://www.mozilla.com/firefox/">a browser with Javascript support</a> are needed.. </div>'; $replace .= "\n\t".'<script type="text/javascript" defer="defer">'; if ($ngg_options['irXHTMLvalid']) $replace .= "\n\t".'<!--'; if ($ngg_options['irXHTMLvalid']) $replace .= "\n\t".'//<![CDATA['; $replace .="\n\t\t".'var '. $obj .' = {'; $replace .="\n\t\t\t".'params : {'; $replace .="\n\t\t\t\t".'wmode : "opaque",'; $replace .="\n\t\t\t\t".'allowFullScreen : "true"},'; $replace .="\n\t\t\t".'flashvars : {'; $replace .="\n\t\t\t\t".'xmlURL : "'.NGGPOLAROID_URLPATH.'nggpolaroidXML.php?gid='.$galleryID.'"},'; $replace .="\n\t\t\t".'attr : {},'; $replace .="\n\t\t\t".'start : function() {'; $replace .="\n\t\t\t\t".'swfobject.embedSWF("'.NGGPOLAROID_URLPATH.'polaroid.swf","ngg_polaroid'.$galleryID.'", "'.$irWidth.'", "'.$irHeight.'", "7.0.0", false, this.flashvars, this.params, this.attr );'; $replace .="\n\t\t".'}'; $replace .="\n".'}'; $replace .="\n".$obj.'.start();'; if ($ngg_options['irXHTMLvalid']) $replace .= "\n\t".'//]]>'; if ($ngg_options['irXHTMLvalid']) $replace .= "\n\t".'-->'; $replace .= "\n\t".'</script>'; return $replace; } } else { add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error fade"><strong>' . __('Sorry, NextGEN Gallery Polaroid works only in Combination with NextGEN Gallery',"nggallery") . '</strong> </div>\';')); }// End Check
- Finally, somewhere along the lines, the SWFObject javascript class which is used by the Polaroid plugin is no longer included by default when the page loads. I’m not sure if there’s a setting somewhere in NextGEN to enable this or what, but the easiest way I’ve found to include it by default is to install the WP-SWFObject plugin. This will add the following line to the html of every wordpress page:
<script src="http://www.your-website.com/wp-content/plugins/wp-swfobject/2.0/swfobject.js" type="text/javascript"></script>
There is probably a better way, but I haven’t found it.
Finally, the code polaroid=ireland,500,600 enclosed in square brackets includes the cool animation below, which shows all the pictures in the “ireland” album with a width of 500×600.
4 Comments so far
Leave a comment
![[del.icio.us]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/facebook.png)
![[Furl]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/furl.png)
![[Google]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/google.png)
![[Slashdot]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/slashdot.png)
![[Technorati]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/technorati.png)
![[Yahoo!]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://www.electrosizzle.com/wp-content/plugins/bookmarkify/email.png)

Thanks so much for this, took care of my issue! – Will
is there a reason this wouldn’t work for version 2.8.6?
I’ve installed the additional component and made the change to the code, but it still doesn’t interpret the [polaroid ...]
I’m not really sure, to be honest. I can assure you that it works with 2.8.6 though, as that’s the current version of WP I’m using.
ah yes, it works, i was my fault, i hadnt properly configured netxgen!.
this rocks! thanks