Integrate RSMediaGallery! with your own extension

This guide is for developers only. If you're an end-user, please read the following articles on how to integrate RSMediaGallery! with your own website:

Starting with RSMediaGallery! R4 you can easily integrate RSMediaGallery! with your own extension.

Basically, you need the following snippet:

      // check if the integration is available
      jimport('joomla.filesystem.file');
      if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_rsmediagallery/helpers/integration.php')) {
        // load the integration helper file
        require_once JPATH_ADMINISTRATOR.'/components/com_rsmediagallery/helpers/integration.php';

        // instantiate
        $gallery = RSMediaGalleryIntegration::getInstance();

        // $tags can be a string with comma separated values, such as:
        $tags = 'first, second, third';
        // ... or an array of tags
        $tags = array('first', 'second', 'third');

        // $options can be either: a JParameter, array or object
        // the list of options is very long and you'll find them below
        $options = array('thumb_width' => 200, 'full_width' => 600);

        // $namespace is by default 'default' and can be omitted
        // however, you can set your own namespace
        $namespace = 'default';

        // display the gallery
        echo $gallery->display($tags, $options, $namespace);
      }
 
Parameters for the $options variable:
  • use_original: use 1 or 0
  • thumb_width: specify the width of the thumbnails (eg. thumb_width => 200)
  • thumb_height: specify the height of the thumbnails (eg. thumb_height => 400)
  • full_width: specify the width of the full images (eg. full_width => 800)
  • full_height: specify the height of the full images (eg. full_height => 600)

Note: Only one of the width or height parameters is taken into consideration - the other will be ignored and calculated automatically.

  • ordering: ordering, title, description, hits, created, modified
  • direction: asc, desc
  • limit: use a number higher than 0 to limit the pictures displayed, or use 0 to show them all
  • show_title: use 1 or 0
  • show_description: use 1 or 0
  • image: use the number of the image you would like to show up (eg. image => "1" to show the first image from the set) and the others will be hidden but still visible in the lightbox when it opens up.
 
Namespacing

By using namespacing, you can define your own stylesheet and modify the RSMediaGallery! look & feel to fit your own extension.

The following classes are used:

  • The thumbnails are actually list items in a user-defined list (<ul>) with the class "rsmg_NAMESPACE_gallery"
  • Each thumbnail is inside a <div> element with the class "rsmg_NAMESPACE_container"

Basically:

      <ul class="rsmg_default_gallery">
        <li>
          <div class="rsmg_default_container">
            <!-- thumbnail here: -->
            <a href="#"><img src="#" /></a>
            <!-- end thumbnail -->
          </div>
        </li>
      </ul>

If you use a namespace different than "default", no RSMediaGallery! stylesheet will be loaded. You'll have to load your own. You can look at /components/com_rsmediagallery/assets/integration/css/listing.css for what a default stylesheet should contain and adjust it to your liking. Please be sure to rename all instances of "default" with the name of your own namespace.

 
Retrieving a list of tags

If you need to display the tags to the user (so he can select what images he wants to display inside the gallery) you can get a list of tags with the following snippet:

      // this returns an array of tags eg. array('first', 'second', 'third')
      // this also assumes you've followed the above recommandation to check if the file exists, load it and then instantiate the integration 
      $tags = $gallery->getTagsList();

4 persons found this article helpful.


Was this article helpful?

Yes No
Sorry about that

You Should Also Read

Setup HOT

The Gallery Layout menu item

What is RSMediaGallery! ?

The Albums Layout menu item

Adjusting the component's look and feel through template overrides