The img tag
The last thing our function has to do, is actually create the img tag and return that.
// create and return the img-tag
$img = '<img src="img.php?f('.$img_file.')'.$attribs.'" '.
'width="'.$out_w.'" height="'.$out_h.'" '.
'alt="'.$img_info["img_alt"].'" border="0">';
return $img;
}
The search form
To search the images, we start with a simple form. We can search by title, description, alt-text and image size. Save the form as, for example, search.html. You can change the form to suit your needs, but basically it would look like this:
<form enctype="multipart/form-data" method="post" action="search.php">
<b>Search image</b><br>
Title: <input name="title" type="text"><br>
Description: <input name="descr" type="text"><br>
Alt-text: <input name="alt" type="text"><br>
Width: <select name="width_expr"> <option value="=">=</option>
<option value=">">></option>
<option value="<"><</option> </select>
<input name="width" type="text"><br>
Height: <select name="height_expr"> <option value="=">= </option>
<option value=">"> ></option>
<option value="<"><</option> </select>
<input name="height" type="text"><br>
Bytes: <select name="bytes_expr"> <option value="=">=</option>
<option value=">">></option>
<option value="<"><</option> </select>
<input name="bytes" type="text"><br>
Type: <select name="type"> <option value="">any</option>
<option value="JPG">JPG</option>
<option value="PNG">PNG</option></select><br>
<input type="submit" value="Search">
</form>
The search script
The input from the search form is sent to search.php. We will write this script now. After doing a search, it should return the images with the appropriate data. The user should also be able to click on the images for a popup larger version.
The first step is the inclusion of the img tag-script. Normally, you would also have to connect to the database. We already did that in the included script, so that's not necessary here.
include("imgtag.php");