Random Images

This is a WordPress widget to randomly pick a number images from a folder of image files, and display them within a sidebar. The main feature I wanted from a plugin that display images, that I could not find, was the ability to link each image individually to a different url so I could link an image to any image gallery or website I chose. There are a number options to set or adjust within the Design > Widgets admin panel.

Current Features

  • Choose the number of images to display
  • Adjust the size of the images
  • Link the images to a url globally or individually
  • Open the link in the same or new window
  • Display image descriptions
  • Various styling options including the widget list class, the title, the block of images and an inner title, and each image.

Possible Future features

  • Allow multi instances of the plugin
  • Make this a generic widget that can be used elsewhere within WordPress other that the sidebar.

Requirements

Works with versions of WordPress from 2.5.1 up 2.7. It may well work with earlier versions although they have not been tested… and if you are running an earlier version than 2.5 then you should maybe think about upgrading. If you have tried and tested this widget with a different or earlier version please let me know.

Download

Download the latest version (0.9.1) of alos_Random_Images

Version History

0.9.1   (21-Dec-2008)

  • Added a stylable ‘inner title’ (see documentation)
  • Improved styling options (widget list class, alos_block, inner title, alos_img) (see documentation)
  • Styling now uses the ‘widget’ class so the widget title and widget spacing is the same as the other widgets in your sidebar (providing you choose the same heading tag (<h2> for example)
  • Fixed to prevent the same image from being displayed twice on the same page
  • Added support for gif and png image files

0.9   (18-Sept-2008)

  • First public release


Documentation

Installation is straightforward, download the latest version and unzip to a local folder. Upload the file alos_randomimg.php to your wordpress plugins folder. Sign in to your wordpress admin panel and activate the ‘aLoS Random Images’ plugin and then go to the Widgets section and add the widget. Create a new folder to contain your images, I would suggest a folder called ‘images’ within your plugins folder into which you can then upload your images.

There are a number of options that can be set as follows:

Title – This is the title of this widget in your sidebar and will be formatted according to your current theme. It can be left blank.

Title styling – Two boxes to enter some html to style the title. It is likely your theme will use a heading tag so try <h2> and </h2> or perhaps h3. Using the same styling as the the other widgets in your sidebar will result in the title looking the same as the other widgets and also will change to any new style should you change the styling in the stylesheet.

Inner title -This is another title, or any text you like, that is displayed within the alos_block style. It is designed to be separate from the standard widget title so you can either use it for additional information or leave the widget title blank.

Inner title styling – Two boxes to enter some html to style the inner title. As an example try <small><strong> in the first box and </strong></small> in the second.

Number of images – the number of images that will be displayed. Cannot be blank and will default to ’1′.

Images location – the location of the images relative to the root folder of your wordpress installation. The default, and suggested value, is /wp-content/plugins/images/

Width and Height – the longest side will be adjusted to fit to the appropriate size. If either width of height is left blank, and is the longest side, then the original image size will be used.

Use global link - selects whether to use the following global image link for all images.

Global image link – a url to use for all images to link to unless overwriten by an individual link.

Use individual links – the widget can link your images individually to different urls. These urls are stored in a data file ‘alosimgdata.csv’ containing filenames, optional descriptions and urls. The file is placed in the same folder as your images. The format of an individual line in the file is shown in the supplied sample file.

Show image description – if the data file alosdataimg.csv is present and descriptions are present they will be displayed below the image.

Open links in new window – opens an image url in a new window rather than the current one.

Styling

It is possible to style the whole widget using the alos_widget css class. This style encompasses the whole widget so adding a background colour for example will affect the background of the standard widget title, if you use one. The block containing the images can be styled with CSS using a class called ‘alos_block’. Each image can be styled with the alos_img class. You can add the following style section to the bottom of your themes style.css file and make adjustments to it as necessary.

/* aLoS Random Image widget styles */
.alos_widget {}
 
.alos_block {
margin: 0 0 2.5em 0;
background:#fff;
padding: 0;
border:0px solid #ddd;
text-align:center;
}
 
.alos_img {}
/* end of aLoS Random Image widget styles */

Leave a Reply