the magic touch for Wordpress image galleries

Simplest Gallery API

 

slider-2Are you a developer?

Do you have a working demo of a unique, great-looking photo gallery javascript, or HTML/CSS layout?

You can make it available to all wordress users in just 1 hour of work!

Learn today how to make a layout style plugin for Simplest Gallery and distribute it/sell it: there thousands of active users installations waiting for your work!

Key concepts

  1. Thousands of users have got the Simplest Gallery plugin to have a quick lightbox-style gallery at hand for their WordPress sites
  2. Simplest Gallery provides a layer on top of which many gallery styles can be built. This way, a user can easily apply a new style to any existing gallery in his/her site.
  3. To create a new style layout is simple: you create a wordpress plugin taking one of ours as an example, and modify it so that it uses your one gallery HTML/CSS/javascript code instead of our own. See our tutorial below.
  4. Once you have created yur plugin and tested it, send it to us for publication or simply distribute it as you like. Many users are striving to try out new gallery styles, including yours!

Tutorial: How to make your unique Simplest Gallery style addon

  • Have a demo of your gallery style at hand, on a plain HTML page, for your own reference and convenience
  • Download the jQuery Cycle Slideshow addon., or modify the lightbox.php file which is included in the new 4.0 version of the plugin.
  • Look at our API documentation below, and modify the style plugin so that it generates your own gallery style instead of the provided one.
    The code is documented and the plugin code is short, it’s fairly easy to edit it to suit your needs.
    Be sure to rename it and include your credits, site, etc.
  • Test your plugin on the most recent release of WordPress
  • Submit your work! – please contact us first with the contact page and let us have an URL where we can see your plugin working. We will contact you for agreements.

All open source, free addons are welcome and, if functional, will be published on this site and credited to the developer

You can ask us to sell your gallery addon and that we share revenues – check with us!

 

Simplest Gallery API

What your gallery style plugin needs to have

Your gallery style plugin needs to have:

  • An inititalization function, where it should register to Simplest Gallery system (basically, you have to let WP know that a new gallery style is available). The function to be used is the following:
sga_register_gallery_type( $uniq_gallery_style_id, $gallery_style_name, $render_callback, $header_callback, $scripts_array, $css_array )

Parameters

$uniq_gallery_style_id : This must be a simple string and must be unique in the world of Simplest Gallery. This string will be used by the system to represent yur specific gallery style.
Existing syles already used so far (these cannot be used beacuse they have been already taken) are:

  • lightbox
  • lightbox_labeled
  • cycle
  • lightview

$gallery_style_name : Human-readable name of your gallery style. Place here anything you like. This will be seen by the user in the Gallery Style dropdown.

$render_callback : Name of your function which will render a gallery. This function must be implemented in your own plugin using a specific list of parameters, more detailed info about this below.

Gallery-rendering function Example

The following is an example of a gallery rendering function, more detailed info about this below.

// This is a the gallery-rendering function. We don't need to care about gathering images because the Simplest Gallery plugin does this for us.
 // First parameter ($images) is an array of images data (images of the gallery to be rendered)
 // Second parameter ($thumbs) is an array of thumbs data (unused here)
 // data here means that each image/thumb is represented by an array. Each position holds a specific thing:
 // 0=URL,1=width,2=height,3=unused,4=ID,5=Label
 // Third parameter is the post ID 
 // Fourth parameters is the gallery ID, representing the progressive gallery number in order of appearence in the page
 // Returns: HTML for the rendered gallery.
 // Note: Scripts inclusion, CSS inclusion and header-specific code should not go here (the sga_register_gallery_type function provides a way to manage them, already
 function mygallery_render($images,$thumbs,$post_id=NULL,$gall_id=NULL,$attrs=NULL) {
 $html_id="mygallery_".$post_id.'_'.$gall_id;
$output = '';
$output .= "<div class=\"$html_id\">\n";
 $output .= "<!-- Gallery rendered code should be here ... -->\n";
 $output .= "\n</div><!-- /$html_id -->\n";
return $output;
 }

$header_callback : Name of your function producing necessary html code to be put in header of the page.
If your gallery requires some specific code to be executed in the page header you can put it here. If this is not needed, you can define a function returning a null string.

function mygallery_header() {
 return '';
 }

$scripts_array : Assoc array of scripts that need to be loaded for your gallery to work. If these script have dependancies, you can specify so here.
The format of the array is the same as in WP’s function wp_enqueue_script(): scriptid=>array(scriptpath,script_version_canbe_in_footer,dependsfrom)

$css_array : Assoc array of CSS that need to be loaded for your gallery to work. This mimics WP’s function wp_enqueue_style() and the format is: cssid=>csspath

 

 

Rendering the gallery

The core of your plugin is the gallery-rendering function. Just stick to the example below for input parameters, and write the code by following your own gallery demo page.

The gallery-rendering function should accept these parameters as input:

$images : array of images
$thumbs : array of the thumbnails. Each position holds a specific thing: 0=URL,1=width,2=height,3=unused,4=ID,5=Label

$post_id : ID of the post (useful for gethering additional post-specific settings)
$gall_id : progressive number of the gallery (useful for disambiguating between galleries, for putting more than 1 gallery in the same post) starting from zero and onwards

$attrs – attributes of the gallery shortcode: might be used to pass further options (eg. width, transitions, effects, colors)

return: HTML-rendered output (string)

Sample gallery-rendering code

function sample_render($images,$thumbs,$post_id=NULL,$gall_id=NULL,$attrs=NULL) {
 $html_id="mygallery_".$post_id.'_'.$gall_id; // With this I an assign a unique ID to each gallery hence mutiple galleries can appear in the same page
$output = '';
$output .= "<div class=\"$html_id\">\n";
 $count=0;
 foreach ($images as $im) {
$th=$thumbs[$count];
 $output .= "<hr/><h3>Image $count</h3>\n";
 $output .= htmlspecialchars(print_r($im,true));
 $output .= "<hr/><h3>Thumb $count</h3>\n";
 $output .= htmlspecialchars(print_r($th,true));
 $output .= "<hr/>\n";
$count++;    // Advance to next image
 }
 $output .= "\n</div><!-- /$html_id -->\n";
return $output;
 }

 

Submitting your gallery style plugin

You can either publish a wordpress plugin by following the WordPress guidelines, or you can contact us so that we can test the plugin, and decide together the policy for its publication (free, paid, donations, etc.)

Questions?

In case of doubts just contact us