Forum Moderators: phranque

Message Too Old, No Replies

Allowing user to control content shown to him/ her

         

dmmh

4:27 pm on Feb 8, 2006 (gmt 0)

10+ Year Member



Personaly I like it when a site allows you to control, to a certain extend, the way and the amount of content shown to you.

Currently I am contemplating to allow the user to choose the window width and height for javascript popups, which are rare on my site, but there are a few, the most important/ used one would be a image viewer.
I would also like it for the user to be able to chose the size of resized images so they will fit to that window neatly.
These variables will be stored in the DB and the values will be stored as session variables upon login, if nobody is logged, the session variables will already be initiated via a simple file include.
But I can see some downsides, one would be server performance.

I have a couple of functions which resize images and they basically all do this:
- check if original image exists
- if so, check if thumbnail was already created
- if so, check wether or not the size is the same as the arguments passed to the function, if so, echo to browser, else re-create thumbnail
- else make a thumbnail and store it in a subfolder, which is also created inside the function
- else echo error message

now if I would allow the user to specify the size he/ she wants her thumbnails in, they will be re-created a lot of time and the older file will constantly be overwritten. What happens if 2 user open the same file simultaniously? Will this work?

Any other comments are welcome!

joaquin112

7:41 pm on Feb 8, 2006 (gmt 0)

10+ Year Member



yeah it will work

jomaxx

7:58 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to make a single size of thumbnail (the largest available), and simply use Javascript/HTML to scale up or scale down the image. Letting the browser do the resizing may not be visibly worse than having your server create a custom resized image.

Browsers in general are not great at this, but they're not bad and hey, they're only thumbnails.

jomaxx

8:08 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



P.S. If you're set on resizing the images yourself, put the height and width in pixels into the filename, and dynamically display that filename (creating it if it doesn't already exist). Otherwise it'll be a never-ending process of resizing thumbnails and re-resizing them.

dmmh

8:20 pm on Feb 8, 2006 (gmt 0)

10+ Year Member



im quite anal about how the visual appearance is of everything and have always found the way browsers scale down images immensly bad, so this is a no go for me

your other suggestion could work, but it would could me a lot of disc space
some movies have 100 images, so if I finally have the 10000's movies I intend to have in the DB, this would require massive file storage.
But by then, I might be able to afford it, who knows :p

jomaxx

8:23 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Depends on your interface. If you only give users a choice between small, medium and large thumbnails, for example, then that's only 3 images required. Very manageable, and once you create the thumbnail one time then there's no further CPU overhead.

henry0

8:52 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Create thumb.
Load it in a temp
Thumb's lifespan = time a given user is on site
User exits (logout) or session expires
Dupe in temp is deleted.