NP_RandomImg.php

This plugin can be used to show a random image on your Nucleus blog and link these images to somewhere else.

General Plugin info
Current Version: 1.3
Download: http://foto-cs.de/blog/downloads/NP_RandomImg-1.3.tgz (format: tgz, size: 3.0 kB, 2 files) or here
Forum Thread: http://forum.nucleuscms.org/viewtopic.php?p=34902#34902
Author: Carsten Schurig (cs42) http://foto-cs.de/blog/

Installing

  1. Unpack the file and upload the contents to your plugin directory
  2. Install the plugin…
  3. Set the options in your blog settings page and add <%RandomImg%> to your skin

How to use the plugin

Besides showing a random image on your page, with this plugin it is possible to

  • define a section title
  • define a title for every image (is used as alt tag too),
  • specify the dimensions (width and height property),</li>
  • give a place to link this image to.

Available SkinVar

  • use <%RandomImg%> to show an image on your page
  • use <%RandomImg(title)%> to get the section title text

Options

All options are blog specific, so they are in the blog settings area.

  • Section title: a text to use as title for your random image section
  • Where are the images?: While you could give a full path to every image, you can define a base path for all images here, e.g. /images. The plugin does not prepend anything other to the image href than this parameter.
  • Base to a gallery to link to: If you want link these images to a gallery you can define a base path to the gallery here. For the definition of the file to link to, see below.
  • The definitions for the images to display: Here you define the parameters of the images to display. The definitions of one image are given per line and the fields are seperated by a pipe. The fields are:
    1. image file name
    2. file name to link to
    3. image title
    4. width of image
    5. height of image

Empty fields are ignored and to get valig XHTML output, the properties are dropped. If no image file name is given, no img tag is set and if the file name to link to is empty, no link is defined. A new line starts a new definition, empty lines are supposed to be ignored. So if you would like to show an image thumb.jpg with a title of This is a nice picture, a width of 100 and heigt of 200, and like to link it to sample.html you have to add:

thumb.jpg|sample.html|This is a nice picture|100|200

Bugs

  • You could say it's a bug, that the image dimensions are not inserted automatically, but this has been done one purpose:
    1. it's my first PHP code, so I did want to keep the code as simple as possible,
    2. it should be faster than to get the image dimensions using some additional library (e.g. GD)

History

  • version 1.3 [2005-07-10]:
    • added the section title option
  • version 1.2 (first published version) [2005-02-27]:
    • moved the image definitions from a file to a blog setting, so it's editable from the blog settings page [2005-04-27]
  • version 1.1:
    • code clean up for release
    • added some empty field checking, so that valid XHTML code is created, even if fields are empty
  • version 1.0:
    • initial plugin, based on NP_Random v1.2, not released (just used on my blog)

Plugin review

NP_RandomImg version 1.3 works with Nucleus CMS 3.31 - 2007-10-28 Armon

randomimg.txt · Last modified: 2010/09/01 22:05 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki