Welcome Guest, Not a member yet? Register   Sign In
Image Randomizer
#1

[eluser]Dregond Rahl[/eluser]
Hey Guys,

So Im working on making an image randomizer. Where the user will have a static URL

domain.com/random.png

but different images will load for it. The user can upload files select them by URL and such.

My Question is, what is the best way to store the URL information in the database?


Example fields

random_url = domain.com/random.png

url_list = domain.com/img1.png, domain.com/img2.png, domain.com/img3.png, domain.com/img4.png


ALSO, would I need to include() them or use file_get_content() to display the different images, or is there are a more efficient method?


here is an example randomizer, although its written in ASP by someone else.

http://r2.mrfrufru.com/dregondrahl/siggy.jpg


Thanks for any help,
Dregond
#2

[eluser]TheFuzzy0ne[/eluser]
If you're just outputting an image with no HTML, you'll need to send the correct headers first.

I'm a bit stuck about "the best way to store the URL information in the database", since I don't really understand what you need to store or why.
#3

[eluser]Dregond Rahl[/eluser]
well since its for different users, each random image needs to be stored in a database. For example

Random Image Link : domain.com/random_1.png

Images For The Randomizer:

domain.com/img1.png
domain.com/img2.png
domain.com/img3.png
domain.com/img4.png


So those images need to be stored somewhere, so then if you make another new random image


Random Image Link 2 : domain.com/random_2.png

Images For The Randomizer 2:

domain.com/img5.png
domain.com/img6.png
domain.com/img7.png
domain.com/img8.png
#4

[eluser]TheFuzzy0ne[/eluser]
How many images is a user allowed? Are they accessible by other users?
#5

[eluser]Dregond Rahl[/eluser]
The random link can be accessed by anyone domain.com/random_1.png. but editing of the values is done only by the user to created the randomizer. Max of 10 images per randomizer.
#6

[eluser]TheFuzzy0ne[/eluser]
I'd suggest either numbering your stored images, and storing them by number (this can be the insert_id() value from the database if you do the insert first), or using a UUID, and then linking that to your database. In the database, you can have three fields.

id user_id image

The ID can be used for access, and might be an ideal candidate for UUIDs, so you'd access images by UUID instead of ID.
#7

[eluser]Dregond Rahl[/eluser]
Thanks for that, ill look into it. But what abt the images in the randomizer? wouldn't I need another field with them ?
#8

[eluser]jedd[/eluser]
How random is random?

Can you generate a new set of random pictures every 30 minutes, say, for all users for that period? Easily done with a cron job. Obviously adjust frequency to taste down to 60 seconds.

If every hit needs to be random all over again .. then obviously a) a more interactive approach is required, and b) your requirements need reevaluating. Wink
#9

[eluser]Dregond Rahl[/eluser]
I mean on refresh its a different picture, out of the selected ones.
I wish could add images here so you can see XD. o0o0o ill make a test page *goes to upload test page*

Here you go : http://uqyg.com/

the image on the main page is random, when you refresh its a different image =]
the service it uses is major slow, thats one of the reason i want to start my own.

Thanks for everyones help =]




Theme © iAndrew 2016 - Forum software by © MyBB