Previous Thread
Next Thread
Print Thread
Rate Thread
#323143 01/17/2019 9:05 AM
Joined: Jul 2001
Posts: 808
Zarzal Offline OP
Coder
OP Offline
Coder
Joined: Jul 2001
Posts: 808
There are 2 ways to get a nice random image island box.
The first code will show a random picture and if you click the box it takes you to the gallery which contains the image. Copy & Paste it in a custom island and set the generation time as you like. I use 15 minutes.
PHP Code
/* PHP CODE HERE */
$query = "
SELECT
`POST_ID`, `FILE_DIR`, `FILE_NAME`
FROM
`
{$config['TABLE_PREFIX']}FILES`
WHERE
`FILE_DIR`<>''
ORDER BY
rand()
LIMIT
1
"
;
$sth = $dbh->do_query($query,__LINE__,__FILE__);
list(
$postId,$fDir,$fName) = $dbh->fetch_array($sth);

/* BODY HERE */
$body = <<<EOF
<div class="p2" style="height:180px;overflow:hidden;position:relative;width:180px;display:inline-block;">
<a href="
{$config['BASE_URL']}/ubbthreads.php?ubb=showgallery&Number=$postId">
<img src="
{$config['BASE_URL']}/gallery/$fDir/medium/$fName" alt="" title="" class="p2 cp oi" style="position:absolute;left:-100%;right:-100%;top:-100%;bottom:-100%;margin:auto;min-height:100%;height:180px;">
</a>
</div>
EOF;


This second code is nearly identical. But if you click the image in the box it open the image in a lightbox and dont take you to the gallery.
PHP Code
/* PHP CODE HERE */
$query = "
SELECT
`POST_ID`, `FILE_DIR`, `FILE_NAME` , `FILE_DESCRIPTION`
FROM
`
{$config['TABLE_PREFIX']}FILES`
WHERE
`FILE_DIR`<>''
ORDER BY
rand()
LIMIT
1
"
;
$sth = $dbh->do_query($query,__LINE__,__FILE__);
list(
$postId,$fDir,$fName,$fDesc) = $dbh->fetch_array($sth);

/* BODY HERE */
$body = <<<EOF
<div class="p2" style="height:180px;overflow:hidden;position:relative;width:180px;display:inline-block;">
<a href="
{$config['BASE_URL']}/gallery/$fDir/full/$fName" data-lightbox="gallery" data-title="$fDesc">
<img src="
{$config['BASE_URL']}/gallery/$fDir/medium/$fName" alt="" title="" class="p2 cp oi" style="position:absolute;left:-100%;right:-100%;top:-100%;bottom:-100%;margin:auto;min-height:100%;height:180px;">
</a>
</div>
EOF;


Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,138
Joined: July 2001
Forum Statistics
Forums63
Topics37,557
Posts293,856
Members13,847
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,819
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 70
Gizmo 16
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2021 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Snapshot build 20210915)
Responsive Width:

PHP: 7.3.29 Page Time: 0.009s Queries: 16 (0.004s) Memory: 0.7852 MB (Peak: 0.8216 MB) Data Comp: Zlib Server Time: 2021-10-23 07:12:46 UTC
Valid HTML 5 and Valid CSS