EzPortal - Portal Software for Forums

EzPortal Forums => ezBlocks => Topic started by: krice on April 09, 2010, 11:40:35 am

Title: Random Image Block
Post by: krice on April 09, 2010, 11:40:35 am
Hope this is the place to ask??

I would like to pull a random image from the forums "attached images" that users have uploaded and placed in their post. I believe they are all stored in the same folder.

Could this be done with a php script loaded into a php ezblock?

It would be great if the image would be random every time the page was reloaded.

Thanks, Ken
Title: Re: Random Image Block
Post by: EzPortal on April 09, 2010, 11:43:46 am
I don't have anything premade for fetching image attachments from posts in a forum yet.
Title: Re: Random Image Block
Post by: krice on April 12, 2010, 07:56:18 pm
Does anyone know of a code to be put in a php block or possible html block that would accomplish this without having a premade ez block?
Title: Re: Random Image Block
Post by: krice on April 13, 2010, 09:28:25 am
Thanks Jake, I have seen some html scripts but have not had much success as I don't know it well. Will keep looking. If I find anything I will post up.
Title: Re: Random Image Block
Post by: thellie on August 02, 2010, 03:35:01 am
if people are uploading, does that mean there's a database table storing information?

if so, and you have access to the database (mine is a MySQL db, accessed via phpMyAdmin), then you can run a mysql query, put in in some php code and drop it into the ezblock...

in the query, set it to 'Order by rand()' (leave out the ticks)

i do this already on our site, and am now upgrading it to run everything through smf - inc our admin pages. i have tested dropping in full page php/mysql/html coded pages into ezblocks, and they work fine... do remember to leave out the initial <?php and the final ?> in the ezblock
Title: Re: Random Image Block
Post by: Eddy Matthews on December 01, 2010, 02:34:50 am
I use the following php file to display a random image.... Just follow the instructions given in the file to set it up for your system.

SMF stores uploaded images in smf/attachments

Regards
Eddy