Installing

As usual put the source code in a file called plugin.quickgallery.php and put it in a directory called fp-plugins/quickgallery/

Usage

[gallery=images/subdirectory-containing-images otherparameters..]

where otherparameters is whatever [IMG] parameter you like. I suggest a scale=NN% or a height=NN to get a popup. Please notice that if you have lightbox plugin installed you'll get a lightbox slideshow :)

galleries are automatically wrapped in a div with class=“img-gallery name-of-gallery” where name-of-gallery is a sanitized version of the string images/subddirectory-containing-images; in most cases it will look like imagessubddirectory-containing-images all lowercase, with spaces turned into slashes and non-ascii/accented characters stripped out/converted to plain ascii.

see your generated html in your browser to know how the string looks like

to style every gallery just use .img-gallery{ } in your CSS

<?php
/*
Plugin Name: QuickGallery 
Version: 1.0
Plugin URI: http://wiki.flatpress.org
Description: Quick gallery plugin
Author: NoWhereMan
Author URI: http://www.flatpress.org
*/
 
 
 
// this will tell FlatPress to load the new tags at the very beginning 
 
add_filter('init', 'plugin_quickgallery_tags');
 
// here you define a function. In this case we're creating an acronym tag
 
function plugin_quickgallery_tags() {
       $bbcode =& plugin_bbcode_init(); //import the "global" bbcode object into current function
                                         // this way 
                                         // a) parsing is done only once, and by the official plugin
                                         // b) you create only ONE object, and therefore computation is quicker
        $bbcode->addCode (
                    'gallery',  // tag name: this will go between square brackets
                    'callback_replace_single', // type of action: we'll use a callback function
                    'plugin_quickgallery_gallery', // name of the callback function
                    array('usecontent_param' => array ('default')), // supported parameters: "default" is [acronym=valore]
                    'inline', // type of the tag, inline or block, etc
                    array ('listitem', 'block', 'inline', 'link'), // type of elements in which you can use this tag
                    array ()); // type of elements where this tag CAN'T go (in this case, none, so it can go everywhere)
 
    $bbcode->setCodeFlag ('acronym', 'closetag', BBCODE_CLOSETAG_FORBIDDEN); // a closing tag is forbidden (no [/tag])
 
}
 
// $content is the text between the two tags, i.e. [tag]CONTAINED TEXT[/tag] $content='CONTAINED TEXT'
// $attributes is an associative array where keys are the tag properties. default is the [tagname=value] property
 
function plugin_quickgallery_gallery($action, $attr, $content, $params, &$node_object) { 
     if ($action == 'validate') {
        // not used for now
        return true;
	 }
 
	 global $lightbox_rel;
 
	 $dir = $attr['default'];
	 if (substr($dir, -1)!='/') $dir .= '/';
 
	 $d = substr_replace ($dir, IMAGES_DIR, 0, 7 );
 
     $fs = new fs_filelister($d);
	 $l = $fs->getlist();
 
	 $imgattr = $attr;
 
	 $lightbox_rel = sanitize_title($dir);
 
	 $str = '<div class="img-gallery '.$lightbox_rel.'">';
 
	 foreach ($l as $f) {
 
		$imgattr['default'] = $dir . $f; 
		$str .= do_bbcode_img($action, $imgattr, $content, $params, $node_object);
 
 
	 }
 
	 $lightbox_rel = null;
 
	 return $str . '</div>';
 
}
 
?>
 
res/plugins/nowhereman/quickgallery.txt · Last modified: 2008/07/14 12:00 by nowhereman
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki