WordPress.org

Ready to get started?Download WordPress

Forums

Howto: Create a random header image using a custom function (2 posts)

  1. t31os
    Member
    Posted 5 years ago #

    I've created a basic custom function for use inside theme's...

    It will grab a random image and place it wherever you place the function...

    Instructions for install can be found here...
    http://www.t31os.co.uk/?p=53

    This is the first of 2 functions i'm writing, this one deals with <img src="" /> based images.

    Usage::
    wp_rand_img( $args );
    or
    <?php wp_rand_img( $args ); ?>
    depending how your theme code is laid out..

    Optional arguments::
    border
    width
    height
    alternate text

    Example::
    wp_rand_img();

    Output::
    <img src="themepath/images/myimage1.jpg" border="0" alt="" />

    *where 1 is a random number, function supports 5 images as default*

    Example:: WIDTH, HEIGHT & ALT text
    wp_rand_img('','width="100"','height="80"','my image')

    Output::
    <img src="themepath/images/myimage1.jpg" border="0" width="100" height="80" alt="my image" />

    Please see my website post for more in-depth information on usage...

    If you would like one to randomise CSS background images you'll need to wait for my next post with the CSS based function (shouldn't be long, just few minor bits left to do).

    Let me know what you think, or any suggestions...

  2. asechrest
    Member
    Posted 5 years ago #

    Thanks. :)

Topic Closed

This topic has been closed to new replies.

About this Topic