Hi!
I'm trying to write an "image selector" script that will display thumbnails of images that are stored in a database. Drawing a blank everywhere I look at the moment...
So, the menu needs to pull out the images from the DB, shrink them to thumbnails and display the image name next to it. The value of the image displayed needs to be sent as it's URL when the form is submitted.
This is probably very simple, but I'm quite new to PHP so please forgive me...
Thanks in advance for your help and input!
Displaying images in a drop down menu
Moderator: General Moderators
- mattcooper
- Forum Contributor
- Posts: 210
- Joined: Thu Mar 17, 2005 5:51 am
- Location: London, UK
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
storing images in a database is typically a no-no. This is mostly due to the overhead required to fetch several images. Each image is sent in a seperate stream, thus each image requires a database query, the database server loading the data into memory, transferring to php and sending on to the user. If the image is quite large, this may result in memory overloads. The same goes for thumbnails, instead of fetching the image new every time to shrink it, why not cache the resulting thumbnail on server?
I'd also suggest not sending the full url as it's form value, as that could allow someone to inject their own remote image into the server. Instead, simply reference the image by identifier or something similar. In the database, I'd keep path information to the major file (at least filename), and potentially the thumbnail too.
I'd also suggest not sending the full url as it's form value, as that could allow someone to inject their own remote image into the server. Instead, simply reference the image by identifier or something similar. In the database, I'd keep path information to the major file (at least filename), and potentially the thumbnail too.
- mattcooper
- Forum Contributor
- Posts: 210
- Joined: Thu Mar 17, 2005 5:51 am
- Location: London, UK
Thanks Feyd, I thought that the image/database thing would be out of bounds. So, let's assume that there is a directory for thumbnails, which have been dynamically generated (how??!). I need the drop down menu to display them.
This is for dynamic website generation.. The first option I'm giving users is to choose a header image for their pages. I thought about foing it with a thumbs gallery, but I'm keen to keep this compact.
Can drop down menus actually display images?
This is for dynamic website generation.. The first option I'm giving users is to choose a header image for their pages. I thought about foing it with a thumbs gallery, but I'm keen to keep this compact.
Can drop down menus actually display images?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
technically, it's possible, using CSS background-image attributes on each option. However, if the list is too large for the display, you will have problems. What I would do instead is fake a drop down that in reality is a simple floating pane. This will allow you to add html into it as well, so you could potentially have a 3 x 3 grid or something..
- mattcooper
- Forum Contributor
- Posts: 210
- Joined: Thu Mar 17, 2005 5:51 am
- Location: London, UK