\MLAImageProcessor

Class MLA (Media Library Assistant) Image Processor provides PDF thumbnails for the [mla_gallery] mla_viewer and Media/Assistant thumbnail generator.

Summary

Methods
Properties
Constants
mla_handle_thumbnail_sideload()
mla_process_stream_image()
$mla_debug
No constants found
No protected methods found
$image
N/A
_get_temp_file()
_ghostscript_convert()
_prepare_image()
_mla_debug_add()
_mla_die()
_mla_error_return()
No private properties found
N/A

Properties

$mla_debug

$mla_debug : boolean

Log debug information if true

Type

boolean

$image

$image : \Imagick

Imagick object for the image to be streamed

Type

\Imagick

Methods

mla_handle_thumbnail_sideload()

mla_handle_thumbnail_sideload(string  $input_file, array  $args) : array

Process Imagick thumbnail conversion request, e.g., for a PDF thumbnail

Replaces download_url() in the Codex "Function Reference/wp handle sideload" example.

Parameters

string $input_file

Path and name of the source file relative to upload directory

array $args

Generation parameters

Returns

array —

file attributes ( 'file', 'url', 'type' ) on success, ( 'error' ) on failure

mla_process_stream_image()

mla_process_stream_image() : void

Process Imagick image stream request, e.g., for a PDF thumbnail

Requires mla_stream_file (relative to wp_upload_dir ) in $_REQUEST; optional $_REQUEST parameters are: mla_stream_width, mla_stream_height, mla_stream_frame, mla_stream_resolution, mla_stream_quality, mla_stream_type, mla_stream_fit, mla_ghostscript_path

_get_temp_file()

_get_temp_file(string  $extension = '.tmp') : string

Generate a unique, writable file in the temporary directory

Parameters

string $extension

File extension for the temporary file

Returns

string —

Writable path and file name.

_ghostscript_convert()

_ghostscript_convert(string  $file, string  $frame, string  $resolution, string  $output_type, string  $explicit_path = '') : boolean

Direct Ghostscript file conversion

Parameters

string $file

Input file, e.g., a PDF document

string $frame

Page/frame within the file, zero-based

string $resolution

Output file DPI. Default 72.

string $output_type

Output MIME type; 'image/jpeg' or 'image/png'.

string $explicit_path

Optional. Non-standard location to override default search, e.g., 'C:\Program Files (x86)\gs\gs9.15\bin\gswin32c.exe'

Returns

boolean —

true if conversion succeeds else false

_prepare_image()

_prepare_image(  $width,   $height,   $best_fit,   $type,   $quality) : void

Prepare the image for output, scaling and flattening as required

Parameters

$width
$height
$best_fit
$type
$quality

_mla_debug_add()

_mla_debug_add(string  $message) 

Log debug information

Parameters

string $message

Error message.

_mla_die()

_mla_die(string  $message, string  $title = '', integer  $response = 500) : void

Abort the operation and exit

Parameters

string $message

Error message.

string $title

Optional. Error title. Default empty.

integer $response

Optional. HTML response code. Default 500.

_mla_error_return()

_mla_error_return(string  $message, string  $line = '') : \array(

Log the message and return error message array

Parameters

string $message

Error message.

string $line

Optional. Line number in the caller.

Returns

\array( —

'error' => message )