A Better Image Rotator

by {embed="embeds/article-authors" entry_author="Dan Benjamin" entry_username="danbenjamin" entry_id="14800"}

151 Reader Comment{if "151" > 1}s{/if}

Back to the {if "articles" == "columns"}Column{if:elseif "articles" == "blog"}Post{if:else}Article{/if}
  1. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    I had a reaaly good ranking in Google – until i rolled this out on my entire site. I have consitently held a rank of between number 1 to number 3 of the search results for atleast the last 6 months. If search rankings bother you, consider something else.

    Those having troubles with it finding the INI file… I had to enter my full server path to the ini file. If you dont know this your host will be able to tell you.

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  2. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    I can’t get the captions to work… this is what I put in the .php file:

    # add caption
    $caption = $images[$img];
    if ($caption) {
      printf(’‘, $caption); }

    and added “caption = ” to the .ini file. Can someone help? Thx.

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  3. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    Hi great code works perfect is there a way to out the images at a certain size.

    thanks

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  4. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    I have your script working on my site and am wondering if there is a way to give each image a click-through address?

    I am asking because the images that I want to add to our site are ads.

    Thanks for the great script!  This is my first excursion into PHP and it worked perfectly without any hitches at all.

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  5. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    I liked the simplicity of rotate—except that since it had an image
    path that was fixed, the browser would cache that image.  So if I used
    it as part of my sidebar menu system then it would not change the image
    as I moved from page to page, unless I explicitly reloaded the page.

    I like rotator’s actually writing the link in, and the various features for adding information to it.

    In the long run I can see the possiblity of a suite of similar tools.

    With rotator you must hand edit a file for the directory.  It would make
    better sense to write a file per image. Give the text file the same name as the image file, but a different extension. In this way, the manipulation
    of the file and the image can be done together, without messy edits.

    This also allows for the non-existence of the extra information.

    I’m brand new to php, but I’ve done some perl before.  I’m going to try
    to make a minimalist rotate that writes image links, using bits from
    both programs.

    Thanks for the two progs.

    ***

    Much of the time there is no need to specify the size of the image. That can be offloaded to the browser.  Use your css to specify how big
    you want the image to be in the containing div.

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  6. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    I’ve found this code quite useful, but I too am trying to figure out where to insert a TARGET=_BLANK so as to open links in a new window.

    also of secondary interest would be to add a Border=0 feature

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  7. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    Does anyone get the error messages on lines 44 & 48 of the rotator.php file saying undefined index. I don’t need the id for styling, but have created the id in the style sheet to see if it goes away and it doesn’t. It doesn’t affect the rotator when uploaded but I hate error messages on my testing server. Any help??

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.
    {/if}
    Copy & paste the code below to embed this comment.
  8. {if FALSE != ""} {if:elseif ""} {if:else} {/if}

    In order to get only unique images add the following to rotator.php script above the ‘get the selected image’s css id if one exists’ statements (note: you only require one ‘pick a random image from the parsed config file’ statement):

    //initialise array if it has not been created
    if ( empty($_SESSION) ) {
    $_SESSION[‘selected_pics_array’] = array(“0”);
    }

    // pick a random image from the parsed config file
    $img = array_rand($images);

    //ensures that the image is unique
    while(in_array($img,$_SESSION[‘selected_pics_array’])) {
    $img = array_rand($images);
    }

    //add the image to the list of displayed images
    array_push($_SESSION[‘selected_pics_array’], $img);

    Also put the following above your <html> tag:
    <?php session_start(); ?>

    After adding all of your “<?php showImage(); ?>” statements add the following:
    <?php
    session_destroy();
    ?>

    {if ""} Edit {if member_group == "1"}Delete{/if} {/if} Embed
    {if ""}
    Comments are editable for one week.