Wednesday, April 14, 2004
Image Display Experiments
Yesterday, in a geeky moment (as if having a web log isn’t geeky enough), I figured out how to prevent the proliferation on my web site of web pages devoted solely to displaying images. I created an Image Viewer. This is a web page, which can be linked to from anywhere in the web site, containing an image supplied by the page that links to it. In other words, my medieval literature students can click on the link to an image of Chaucer in the medieval literature web site, and my history of the English language students can click on the map of the Angevin Empire from the web site for that course, and each will go to the Image Viewer web page which loads the image specified in the link. Then a simple “back” link returns the user to the page they started from.
The problem is how to tell the Image Viewer page which image to load. The solution is to place a “query string” at the end of the link on the original page. This is a question mark followed by a variable name such as “image” an equals sign and the value (in this case the address of the image). The URL ends up looking like http://www.randomsite.edu/?image=images/chaucer.gif. That’s easy enough to do. The Image Viewer page is a bit more complicated. It needs a script to parse the query string into a variable name (“image”) and a value (the address). There are lots of scripts like this available on the internet. I experimented with several and found one that is flexible enough to parse multiple variables. That way I can stick one in for the title of the image as well. After pasting in the parsing script, I just needed to write a script to write HTML which prints the title and loads the image. In the end, the solution was so elegant that it’s worth improving. I want to modify the parsing script to handle variables for height and weight. That way I can display images in the image viewer pretty much any way I want by supplying this information when I create the link.
This will save me the trouble of creating new display pages for each image I add to the site in the future. Once I get it perfected, I may well make the Image Viewer scripts available to the public.
The problem is how to tell the Image Viewer page which image to load. The solution is to place a “query string” at the end of the link on the original page. This is a question mark followed by a variable name such as “image” an equals sign and the value (in this case the address of the image). The URL ends up looking like http://www.randomsite.edu/?image=images/chaucer.gif. That’s easy enough to do. The Image Viewer page is a bit more complicated. It needs a script to parse the query string into a variable name (“image”) and a value (the address). There are lots of scripts like this available on the internet. I experimented with several and found one that is flexible enough to parse multiple variables. That way I can stick one in for the title of the image as well. After pasting in the parsing script, I just needed to write a script to write HTML which prints the title and loads the image. In the end, the solution was so elegant that it’s worth improving. I want to modify the parsing script to handle variables for height and weight. That way I can display images in the image viewer pretty much any way I want by supplying this information when I create the link.
This will save me the trouble of creating new display pages for each image I add to the site in the future. Once I get it perfected, I may well make the Image Viewer scripts available to the public.
Comments:
Post a Comment