SnapContentMediaImage Class Reference
[Content Modules]

Content Module for Images. More...

Inheritance diagram for SnapContentMediaImage:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 checkMedia ()
 INSERT BRIEF DESCRIPTION HERE.
 getConfig ()
 INSERT BRIEF DESCRIPTION HERE.
 getFormat ()
 Retrieves image format.
 getHeight ($which= 'original')
 Retrieves height of image.
 getImageName ()
 Retrieves the original name of the image.
 getOptions ()
 INSERT BRIEF DESCRIPTION HERE.
 getPath ($which= 'original')
 Retrieves path to image on server.
 getSize ($which= 'original')
 INSERT BRIEF DESCRIPTION HERE.
 getURL ($which= 'original')
 Retrieves URL for image.
 getWidth ($which= 'original')
 Retrieves width of image.
 rescaleImages ($oldCM, $options=array())
 Rescale images from old content module.
 setOptions ($options)
 INSERT BRIEF DESCRIPTION HERE.
 updateFileList ()
 INSERT BRIEF DESCRIPTION HERE.
 uploadImage ($tmpFile, $fileName, $options=array())
 Uploads image into this content module.


Detailed Description

Content Module for Images.

Each content module stores information about an image, which has four presized actual images: thumb, medium, display and original. You can select the size used when calling getHTML(). When uploading images into the content module, you can specify the sizes of the subimages (see updateImages() for more).

When generating HTML for an image, you can use the following configuration options:


Member Function Documentation

SnapContentMediaImage::checkMedia (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Reimplemented from SnapContent.

SnapContentMediaImage::getConfig (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

SnapContentMediaImage::getFormat (  ) 

Retrieves image format.

This really just returns the suffix (jpeg or png right now).

Returns:
[string]: image format (jpeg or png)

SnapContentMediaImage::getHeight ( which = 'original'  ) 

Retrieves height of image.

Parameters:
$which [string]: which image size to retrieve height for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive)
Returns:
[int]: height, in pixels, of image, or false if this is an invalid content module

SnapContentMediaImage::getImageName (  ) 

Retrieves the original name of the image.

The original name of the image is what was passed in to uploadImage() as the original file name.

Returns:
[string]: original file name of image

SnapContentMediaImage::getOptions (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

SnapContentMediaImage::getPath ( which = 'original'  ) 

Retrieves path to image on server.

You probably never need to call this method, and if you think you do, try to redesign your application.

Parameters:
$which [string]: which image size to retrieve path for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive)
Returns:
[string]: path on server to requested image

SnapContentMediaImage::getSize ( which = 'original'  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$which [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

SnapContentMediaImage::getURL ( which = 'original'  ) 

Retrieves URL for image.

This method is useful when you need an image URL for embedding into your own custom HTML, instead of using the HTML generated by getHTML().

Parameters:
$which [string]: which image size; one of: 'original', 'thumb', 'medium', 'display' (case sensitive)
Returns:
[string]: URL to image, or false if this is an invalid content module

SnapContentMediaImage::getWidth ( which = 'original'  ) 

Retrieves width of image.

Parameters:
$which [string]: which image size to retrieve width for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive)
Returns:
[int]: width, in pixels, of image, or false if this is an invalid content module

SnapContentMediaImage::rescaleImages ( oldCM,
options = array() 
)

Rescale images from old content module.

This method is the same as uploadImage() except that it uploads from an old content module instead of from fresh files. See uploadImage() documentation for more on the configuration options.

It is up to the caller of rescaleImages() to grab any relevant parts of the old configuration by calling getConfig() on the old content module. This way, it is possible to, say, resize just one image and leave the others as they were.

Parameters:
$oldCM [SnapContentMediaImage]: content module to resize images from
$options [array]: array of resize options
Returns:
[boolean]: success or failure

SnapContentMediaImage::setOptions ( options  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$options [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

SnapContentMediaImage::updateFileList (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Reimplemented from SnapContent.

SnapContentMediaImage::uploadImage ( tmpFile,
fileName,
options = array() 
)

Uploads image into this content module.

This method requires at least two parameters. The first parameter specifies the full path to the file to be uploaded. The file, obviously, must be on the server and accessible to the web server user. The next parameter is the original name of the file. This is useful for when the file to be uploaded was uploaded by the user via a POST request. In that case, you can get the first parameter from $_FILES['foo']['tmp_name'] and the second parameter (original file name) from $_FILES['foo']['fileName']. See the code in snap2.2/tk2/editors/TKSnapMediaImageEditor.php5 for more on how to do this effectively/correctly.

The third parameter is an array of configuration options. These are mostly to specify how the different subimages should be sized. For each of the three resized subimages (thumb, medium and display), you can either specify an explicit size, an explicit scale factor, or a resize mode, which uses built-in defaults. If you do not specify anything, then a lousy scaling algorithm is used where thumbnails are scaled at 25% of the original size, mediums at 50% and display being the same as the original. Below is a list of options and how they should be filled. Note that you should not specify more than one way to resize a given subimage. If you do this, only one of your sizing options will be used and possibly not the one you want.

  • thumbScale: set it to a scale factor between 0.0 and 1.0; each axis of the thumbnail image will be scaled by this factor relative to the original image's size
  • thumbSize: has two subvalues: width and height; allows you to specify exact size of thumbnail image; image will be scaled to that size exactly, but this may result in distortion if the aspect ratio is not kept constant
  • thumb_resize: one of 'wide' or 'square'; 'wide' scales to 150x80 pixels, cropping if necessary to maintain aspect ratio, and 'square' scales to 80x80, also cropping to maintain aspect ratio

For medium and display sizes, the exact same options are available, but substitute 'medium' or 'display' instead of 'thumb' in the option names given above. Note that 'medium_resize' and 'display_resize' only support 'standard', which is 400x400 for medium and 600x600 for display.

If you specify thumbCropScale, mediumCropScale or displayCropScale when you are using xxxScale or xxxSize (but not xxx_resize), then the special crop-scale algorithm will be used to prevent image distortion by keeping the aspect ratio and croppying width or height to prevent minimal loss of image data.

This method will not delete the original file as specified by $tmpFile (this was the case in earlier versions of Snap2). You need to clean up that file in your code. If there is any code within Snap2 that does not do that, it should be fixed, or else image files will leak.

Most errors related to resizing or creating the subimages will be handled gracefully, but it is still possible that large or strange images could result in PHP running out of memory, or some other bad condition. Call this method with care and warn users appropriate when uploading images.

Parameters:
$tmpFile [string]: full path to soruce image file, on this server
$fileName [string]: original name of file (do not include path)
$options [array]: image sizing options, as described above
Returns:
[boolean]: success or failure; with errors set on this object; retrieve with getLastError()


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:03:12 2010 for Common by  doxygen 1.5.6