Wizard’s Toolkit Documentation

Image.php

Wizard’s 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

wtkImgFolderPath()  : image
Image Folder Path
wtkHtmImage()  : HTML
Pass in parameters and HTML for <img > is generated
wtkResizeImg()  : image
Resize Image
wtkMaxSizeImg()  : image
Max Size Image
wtkImagePopWin()  : HTML
Image Popup Window
wtkImageFancyBox()  : HTML
Image FancyBox Window popup
wtkReadDir()  : array<string|int, mixed>
Fill an array with all files in directory tree. Pass parameters for type of files.
wtkFileDisplay()  : array, string, numeric
Generates HTML5 to display images, videos or PDFs.
wtkFileCell()  : string, string, numeric, numeric
Called by wtkFileDisplay this generates HTML to display image, video or PDF.

Functions

wtkImgFolderPath()

Image Folder Path

wtkImgFolderPath( 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

wtkHtmImage()

Pass in parameters and HTML for <img > is generated

wtkHtmImage( 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

wtkResizeImg()

Resize Image

wtkResizeImg( 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

wtkMaxSizeImg()

Max Size Image

wtkMaxSizeImg ( 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 wtkResizeImg 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 wtkResizeImg

wtkImagePopWin()

Image Popup Window

wtkImagePopWin( 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 wtkMaxSizeImg

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

wtkImageFancyBox()

Image FancyBox Window popup

wtkImageFancyBox( 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

wtkReadDir()

Read Directory and fill array with all files based on File Type passed.

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

Defaults to ‘.’ for same folder as current PHP file but you can pass in the folder you want to search. This will find all files in that folder and all subfolders.

Second parameter passed defaults to ‘image’ and will fill the array with all files with case insensitive file extension of: jpg, jpeg, png, gif. If pass in ‘video’ fills array with all files with with case insensitive file extension of: mp4, mov, webm, ogv If second parameter is anything else then only files with that exact file extension are retrieved.

Parameters
$fncDir : string = '.'

pass in directory to search. Use ‘.’ for current directory.

$fncFileType : string = 'image'

defaults to ‘image’. Pass in ‘image’, ‘video’ or any single file extension you desire.

Return values
array<string|int, mixed>

array of files within a folder tree based on $fncFileType passed

wtkFileDisplay()

This generates HTML5 to display images, videos or PDFs showing them several across and expanding the view to display them when clicked.

wtkFileDisplay( array $fncFileArray , string  $fncShowName , number  $fncFilesPerRow ) : HTML

This generates HTML5 to display images, videos or PDFs showing them several across and expanding the view to display them when clicked.

You can use wtkReadDir to create an array of files to pass to this function. The files can be in this folder and/or in subfolders. This function shows all the files in the passed array.

If you do not pass the $fncFilesPerRow parameter it sets that based on count of files in $fncFileArray.

  • if 1 to 3 then show on one line
  • 4 photos show in 2 lines of 2
  • 5 to 6 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 16 show 4 per line
  • more than 16 then show 6 per line

If $fncFilesPerRow does not equal 0,1,2,3,4, or 6, then invalid so ignored and calculates based on above logic.

Parameters
$fncFileArray : array
containing files you wish to display
$fncShowName : string
Defaults to ‘N’; if ‘Y’ passed then uses file name for descriptor text
$fncFilesPerRow : numeric
Defaults to 0 but can be overriden. If zero then decides based on count of files in array
Return values
HTML

showing all files from $fncFileArray array

wtkFileCell()

Called by wtkFileDisplay this generates HTML to display image, video or PDF.

wtkFileCell( array $fncFileArray , string  $fncShowName , number  $fncFilesPerRow ) : HTML

Probably should never be called directly. This receives variables from wtkFileDisplay and returns HTML to go within a File Display spread.

Parameters
$fncFile : string
contains name of file to display
$fncShowName : string
Defaults to ‘N’; if ‘Y’ passed then uses file name for descriptor text
$fncFilesPerRow : numeric
determines how many files to display across a row
$fncRowCntr : numeric
contains counter for row to determine if should start new row
$fncRowCntr : numeric
contains counter for row to determine if should start new row
Return values
HTML

returns HTML to display file that was passed

Search results