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. |
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:
SnapContentMediaImage::checkMedia | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
Reimplemented from SnapContent.
SnapContentMediaImage::getConfig | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
SnapContentMediaImage::getFormat | ( | ) |
Retrieves image format.
This really just returns the suffix (jpeg or png right now).
SnapContentMediaImage::getHeight | ( | $ | which = 'original' |
) |
Retrieves height of image.
$which | [string]: which image size to retrieve height for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive) |
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.
SnapContentMediaImage::getOptions | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
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.
$which | [string]: which image size to retrieve path for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive) |
SnapContentMediaImage::getSize | ( | $ | which = 'original' |
) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
$which | [TYPE]: 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().
$which | [string]: which image size; one of: 'original', 'thumb', 'medium', 'display' (case sensitive) |
SnapContentMediaImage::getWidth | ( | $ | which = 'original' |
) |
Retrieves width of image.
$which | [string]: which image size to retrieve width for; one of: 'original', 'thumb', 'medium', 'display' (case sensitive) |
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.
$oldCM | [SnapContentMediaImage]: content module to resize images from | |
$options | [array]: array of resize options |
SnapContentMediaImage::setOptions | ( | $ | options | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
$options | [TYPE]: DESCRIPTION |
SnapContentMediaImage::updateFileList | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
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.
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.
$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 |