Publishing images on the web is nice, but tedious. It would be nice if we could use a system that automates the uploading, storage, converting and resizing of our images. We could feed that system our images once, and retrieve them later in many different formats. In this article, we will write some scripts that come close to this ideal system. PHP and the GD-library will provide us with an easy method of uploading, searching and publishing our images. (This article is a follow-up on part 1).
In this second part, we will write scripts that you can use to retrieve images and search your image database. To be able to use these scripts, you should have read the first part of this article and saved the scripts we wrote there. You also need the image resize script explained in an earlier article. (This was also stated in part 1.)
What we will do in this second part
We will write scripts that allow us to:
- automatically generate an appropriate img tag for an image
- search and find our images
- a popup that shows us a larger version of an image. (This isn't that difficult, but it's a nice example of how we can use our scripts to create img tags.)