GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Looking for a random image script in PHP (https://gfy.com/showthread.php?t=992170)

Ad-Min 10-12-2010 03:34 PM

Looking for a random image script in PHP
 
Hi guys,i am looking for a random image script in php.
I´ve checked many sites but i am not able to find what i am looking for.
I would like to rotate a couple of thumbs from a folder randomly.
I have about 20 folders and all the thumbs should go on one page.
Actualy 20 rotating thumbs on the page (20 folders x 5 thumbs per folder).
No java for now,i need it in php.
Any suggestions?

Thanks in advance

newB 10-12-2010 03:50 PM

Here's one I used to make a fake TGP a long time back and it worked like a charm in that it allows for link attributes. If you don't want to link the images, just leave the fields blank in the ini sheet.

http://www.alistapart.com/articles/betterrotator/

Supz 10-12-2010 04:53 PM

Take a look at AIRS from BigDotMedia

http://www.bigdotmedia.com/airs.php

garce 10-12-2010 05:00 PM

You can try this is you just want something simple: http://ma.tt/scripts/randomimage/

HomerSimpson 10-12-2010 05:26 PM

rstgp or contact me to write you something custom

www.awmzone.com/services

fris 10-12-2010 07:07 PM

Quote:

Originally Posted by newB (Post 17600595)
Here's one I used to make a fake TGP a long time back and it worked like a charm in that it allows for link attributes. If you don't want to link the images, just leave the fields blank in the ini sheet.

http://www.alistapart.com/articles/betterrotator/

i would use this, but a modified version so you dont have repeating images.

http://randaclay.com/tips-tools/mult...ge-php-script/

Ad-Min 10-13-2010 12:07 PM

Thanks a lot guys :thumbsup,i would rep you all but i am not able :disgust !

SmellyNose 10-13-2010 12:18 PM

I wrote this in the GFY quick reply box, so who knows if it has errors. :thumbsup
Code:

<?php
define('BASE_DIR', '/var/www/mysite/images/'); // Where are your images?
define('IMAGE_LIMIT', 10); // how many images to show?

$files    = glob(BASE_DIR.'*');
$images = Array();

if(empty($files)) {
    die("Hey, dude, there are no files. What happened?");
}

foreach($files as $v) {
    if(is_dir($v)) {
        foreach($files as $v) { // This should be a function which can loop through further sub directories if needed
            //get exif image type, if it's an image append to array
            $images[] = $v;
        }
    } else {
        $images[] = $v;
    }
}

shuffle($images); // Randomise the array
for($i=0;$i<IMAGE_LIMIT;$i++) {
    $img = $images[$i];
    if(empty($img)) {
        break; // Might be best doing a foreach above whilst keeping $i as a loop counter and breaking the loop once you reach the limit
    }
    $img_src = end(explode("/", $img));
    echo "<img src='{$img_src}'/>";
}


Ad-Min 10-13-2010 01:32 PM

Quote:

Originally Posted by SmellyNose (Post 17603350)
I wrote this in the GFY quick reply box, so who knows if it has errors. :thumbsup
Code:

<?php
define('BASE_DIR', '/var/www/mysite/images/'); // Where are your images?
define('IMAGE_LIMIT', 10); // how many images to show?

$files    = glob(BASE_DIR.'*');
$images = Array();

if(empty($files)) {
    die("Hey, dude, there are no files. What happened?");
}

foreach($files as $v) {
    if(is_dir($v)) {
        foreach($files as $v) { // This should be a function which can loop through further sub directories if needed
            //get exif image type, if it's an image append to array
            $images[] = $v;
        }
    } else {
        $images[] = $v;
    }
}

shuffle($images); // Randomise the array
for($i=0;$i<IMAGE_LIMIT;$i++) {
    $img = $images[$i];
    if(empty($img)) {
        break; // Might be best doing a foreach above whilst keeping $i as a loop counter and breaking the loop once you reach the limit
    }
    $img_src = end(explode("/", $img));
    echo "<img src='{$img_src}'/>";
}


Thanks but i have solved the problem already.


All times are GMT -7. The time now is 06:05 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123