Displaying a Thumbnail

The process of outputting a series of thumbnail images to the browser occurs in two steps. First, you create a script that outputs an image; then you use this script file as the source for an img tag.

The code in Listing 6-7 shows the script file for outputting an image. It retrieves the path and size from a query string and uses these values to construct a thumbnail and then display it (in this chapter's downloads, this is the file getthumb.php).

Listing 6-7. Constructing and displaying a thumbnail image
 <?php //this file will be the src for an img tag require 'ThumbnailImage.php'; $path = $_GET["path"]; $maxsize = @$_GET["size"]; if(!isset($maxsize)){ $maxsize = 100; } if(isset($path)){ $thumb = new ThumbNailImage($path, ...

Get Object-Oriented PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.