Random Image (6 posts)

  1. singleton
    Posted 10 years ago #

    The Jakarta script displays an image at the bottom of each post, using this code:
    <center><img src="<?php bloginfo('stylesheet_directory'); ?>/images/hr.gif" alt="The End"/></center>

    Does anyone know of any way to display one of n images (hr1.gif, hr2.gif, hr3.gif, etc)

    What that would require was taking some index number and doing a "modulo" function, for example if I had three different images hrmodulo(index,3).gif would get it, but I dont know enough about php to know how to code that. Can anyone help me?

  2. jwurster
    Posted 10 years ago #

    Look for a plugin in http://codex.wordpress.org/plugins.
    There are some random image display plugins.

  3. singleton
    Posted 10 years ago #

    All I saw was PhotoPress http://isaac.wedin.org/photopress/ which did a LOT more than what I wanted, and seemed to only provide one random graphic inserter

    I need something that I can use more than once in a template (use one gets images 1a, 1b, 1c and use two gets 2a, 2b, and 2c)

    I am pretty sure the modulo approach I suggested would work, if someone can tell me of a tag that is numeric, and how to use php to form the name of an image that will then be displayed

  4. jwurster
    Posted 10 years ago #

    I have used a plugin called multiple-random-img to do what you want. I have also use a plugin call flashfader.

  5. singleton
    Posted 10 years ago #

    flashfader seems to load a flash slideshow, and multiple-random-img seems like overkill, because it is designed for pulling n images from a m (n<m) database

    I really need to find a numeric tag I can do a modulo on, and let it generate a number to append to a file name, as described above.

  6. singleton
    Posted 10 years ago #

    I came up with my own solution:

    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/rule<?=rand(1,5)?>.gif">

    randomly selects rule1.gif, rule2.gif,... rule5.gif

Topic Closed

This topic has been closed to new replies.

About this Topic