NewsFeaturesDownloadsDevelopmentSupportAbout Us

Plugin galleryimages

From LifeType Wiki


Name: galleryimages

Download link: http://sourceforge.net/projects/lifetype/files/

License: GPL

Author: The LifeType Project

Description

This plugin allows to retrieve the latest image(s) or random image(s) from your resources, so that they can be displayed anywhere in your blog. This plugin can also display pictures from a certain album if necessary.

Configuration

The plugin does not need to be enabled. Just unzip the galleryimages.zip package in the plugins folder.

The plugin features the following functions:

  • latestImage(): Returns the latest image (only one) that was added to our gallery.
  • latestImage( $album_id ): Returns the latest image that was added to the album with the given identifier.
  • latestImages(): Returns an array with the latest 5 images from any of our albums.
  • latestImages( $maxImages ): Returns an array with as many $maxImages from any of our albums.
  • latestImages( $maxImages, $album_id ): Returns an array with as many $maxImages from the album with the given album id.
  • randomImage(): Returns one random image from any of our albums.
  • randomImage( $album_id ): Returns one random image from the album with the given album identifer.
  • randomImages(): Returns 5 random images from any of our albums.
  • randomImages( $maxImages ): Returns as many $maxImages random images from any of our albums.
  • randomImages( $maxImages, $album_id ): Returns as many $maxImages random images from the album with the given album identifier.

When specifying a certain album, we need to find its album identifier. The best way to do so is via the admin interface, in the "Resources" page we can click in the folder icon for the album whose pictures we'd like to use and look at the URL in the browser address bar. So for example if the URL is http://www.yoursite.com/plog/admin.php?op=resources&albumId=4&page=1, then the identifier of this album is 4.

The only step required to use this plugin is to edit the templates. So for example in order to show the last image added to our resource, no matter from which album:

{assign var=latestImage value=$galleryimages->latestImage()}
<a href="{$url->resourceLink($latestImage)}">
<img style="border:0px;" src="{$url->resourcePreviewLink($latestImage)}" alt="{$latestImage->getDescription()}" />
</a> 

In order to display the latest 5 images from the album whose id is 14:

{assign var=latestImages value=$galleryimages->latestImages('5','14')}
{foreach from=$latestImages item=latestImage}
   <a href="{$url->resourceLink($latestImage)}">
   <img style="border:0px;" src="{$url->resourcePreviewLink($latestImage)}" alt="{$latestImage->getDescription()}" />
   </a> 
{/foreach}

The same can be done when using the randomImages function to show 3 random images:

{assign var=randomImages value=$galleryimages->randomImages('3')}
{foreach from=$randomImages item=randomImage}
   <a href="{$url->resourceLink($randomImage)}">
   <img style="border:0px;" src="{$url->resourcePreviewLink($randomImage)}" alt="{$randomImage->getDescription()}" />
   </a> 
{/foreach}

Notes

The randomImage and randomImages methods will not work when the template cache is enabled, since plugins are not executed when pages are cached. The plugin will calculate the next random image(s) next time that the page is refreshed.

This problem does not exist with the latestImage and latestImages method.