Wizards Toolkit Documentation

Image.php

Wizards Toolkit functions involving images: listing, resizing, displaying.

This can be used without the rest of the WTK library in which case just: include('Image.php'); The img.php and photo.php file must be accesible within the folder this is called from.

All rights reserved.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tags
author
Programming Labs
license
All rights reserved
version
2.0

Table of Contents

wzImgFolderPath()  : image
Image Folder Path
wzHtmImage()  : HTML
Pass in parameters and HTML for <img > is generated
wzResizeImg()  : image
Resize Image
wzMaxSizeImg()  : image
Max Size Image
wzImagePopWin()  : HTML
Image Popup Window
wzPhotoFillArray()  : null
Photo Fill Array
wzPhotoThumbnails()  : HTML
Photo Thumbnails
wzReadDir()  : array<string|int, mixed>
Read Directory and fill array with all non-PHP files.
wzImageFancyBox()  : HTML
Image FancyBox Window popup
wzPhotosSpread()  : HTML
wzPhotosSpread - FancyBox based photo gallery

Functions

wzImgFolderPath()

Image Folder Path

wzImgFolderPath( string  $fncImageName) : image

This prevents getimagesize error when image path is higher in the directory heirarchy

Parameters
$fncImageName : string
Return values
image

name after full web URL path

wzHtmImage()

Pass in parameters and HTML for <img > is generated

wzHtmImage( string  $fncImageName [, string  $fncTitle = '' ][ , string  $fncClass = '' ], string  $fncWidth , string  $fncHeight) : HTML
Parameters
$fncImageName : string
$fncTitle : string = ''

Defaults to blank

$fncClass : string = ''

Defaults to blank

$fncWidth : string

Defaults to '0'

$fncHeight : string

Defaults to '0'

Return values
HTML

image syntax

wzResizeImg()

Resize Image

wzResizeImg( string  $fncImageName , mixed  $fncWidth , mixed  $fncHeight) : image

Pass in image and Width, Height and Type. If both width and height are passed it will use those exact values. If only width is passed it will adjust the height keeping the original ratio. If only height is passed it will adjust the width keeping the original ratio.

Parameters
$fncImageName : string
$fncWidth : mixed
$fncHeight : mixed
Return values
image

HTML using img.php to generate image in correct size

wzMaxSizeImg()

Max Size Image

wzMaxSizeImg ( string  $fncImageName , mixed  $fncMaxWidth , mixed  $fncMaxHeight ) : image

Pass in the maximum width or height you want and this will check the image and then call wzResizeImg function to build it. If the image is smaller than the maximum values sent it will not have the image size changed.

Parameters
$fncImageName : string
$fncMaxWidth : mixed
$fncMaxHeight : mixed
Return values
image

HTML using wzResizeImg

wzImagePopWin()

Image Popup Window

wzImagePopWin( string  $fncImageName , mixed  $fncMaxWidth , mixed  $fncMaxHeight [, string  $fncPath = '' ]) : HTML

Wrappper with popup window for full-size image. Pass in Maximum Width and Height and it calls wzMaxSizeImg

Parameters
$fncImageName : string
$fncMaxWidth : mixed
$fncMaxHeight : mixed
$fncPath : string = ''

Defaults to blank

Return values
HTML

with thumbnail of image and link to popup window with full-sized image

wzPhotoFillArray()

Photo Fill Array

wzPhotoFillArray( string  $fncPhotoName ) : null

Pass in all photo names including their paths then later call wzPhotoThumbnails to generate

Parameters
$fncPhotoName : string
Tags
global

string $gloThumbCntr

global

string $gloThumbArray

Return values
null

wzPhotoThumbnails()

Photo Thumbnails

wzPhotoThumbnails( [ mixed  $fncPhotoWidth = 150 ] [, mixed  $fncPhotoHeight = 150 ] ) : HTML

Generates table filled with thumbnail images with popups. Pulls photos from array filled using wzPhotoFillArray and displays using wzImagePopWin

Parameters
$fncPhotoWidth : mixed = 150
$fncPhotoHeight : mixed = 150
Tags
global

string $gloThumbCntr

global

string $gloThumbArray

Return values
HTML

table showing all photos in $gloThumbArray array

wzReadDir()

Read Directory and fill array with all non-PHP files.

wzReadDir( [ string  $fncDir = 'ImageDir' ]) : array<string|int, mixed>

Pass in a '.' if you want it to be same folder as current PHP file. This includes subfolders.

Parameters
$fncDir : string = 'ImageDir'

Defaults to 'ImageDir'

Return values
array<string|int, mixed>

of non-php files within a folder

wzImageFancyBox()

Image FancyBox Window popup

wzImageFancyBox( string  $fncImageName , mixed  $fncMaxWidth , mixed  $fncMaxHeight ) : HTML

This assumes that all image names in list are unique otherwise FancyBox will not work

Parameters
$fncImageName : string
$fncMaxWidth : mixed
$fncMaxHeight : mixed
Return values
HTML

with thumbnail of image and link to popup window with full-sized image

wzPhotosSpread()

wzPhotosSpread - FancyBox based photo gallery

wzPhotosSpread( int  $fncPhotoCount , string  $fncSQL , array<string|int, mixed>  $fncSqlFilter [, string  $fncImageFolder = '' ] ) : HTML

Pass in SQL to retrieve photos and build photo gallery based on # of photos

Determine size and number of lines for photos based on number of photos

if 1 to 3 then one line
4 photos show in 2 lines of 2
5 to 6 photos show in 2 lines of 3
7 to 8 photos show in 2 lines of 4
9 show in 3 lines of 3
10 to 12 show in 3 lines of 4

Parameters
$fncPhotoCount : int
  • number of photos that will be returned
$fncSQL : string
  • SELECT that retrieves photo URLs from data, must use column names of 'Caption' and 'PhotoURL'
$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncImageFolder : string = ''
  • which subfolder the images are located in, defaults to current folder
Return values
HTML

table with thumbnails and FancyBox to pop full photos

Search results