Sunday, 25 August 2013

Display image with wildcard in src

Display image with wildcard in src

I have a series of photos on a server with a strict naming convention:
"uniqueId-readableName.jpg". I do this because my website database
currently only logs the uniqueID (and some unrelated info), but people
occasionally need to look at the file server directly to browse the photos
(via FTP) so a readable name is useful. For example
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
129084-Laboring at the farm 2013-08-11.jpg
Now, I'm fairly sure the best option would be to set up the database with
a record of the full file names, but I just wanted to see if anyone had
any ideas I may have missed. This question on SO is similar, but here I
have strict naming conventions - not sure if that opens up any
possibilities or not.
I'm applying this to img, but the same idea could be appled to any file
extension (eg, download "789-My Homework.zip" or "123-Family
vacation.zip").
As an example of what I'm looking for, in Windows Explorer you can do a
file search for
0*.jpg
and all of the following files can be returned
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
029084-Laboring at the farm 2013-08-11.jpg
In my case the beginning part is always unique, so I'd like to use
something like 001456-*.jpg and have it return 001456-War Horse.jpg.
Is there any way do this on a website?
<img src="001456-*.jpg" />

No comments:

Post a Comment