validateParam()
* @param int $flags A bitfield, may contain self::TRANSFORM_LATER
* @return MediaTransformOutput
*/
public function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0) {
$params['isFilePageThumb'] = false;
if (!isset($params['width']) || $params['width'] == 0) {
$params['width'] = 800;
}
if (!isset($params['height']) || $params['height'] == 0) {
$params['height'] = 600;
}
if ($params['width'] <= 300 || $params['height'] <= 300) {
$params['isFilePageThumb'] = true;
}
return new GlModelTransformOutput($image, $params);
}
/**
* Check the incoming media parameters
*
* @param string $name
* @param string $value
* @return bool
*/
public function validateParam( $name, $value ) {
echo '';
if (in_array($name, ['width', 'height'])) {
return $value > 0;
} else if (in_array($name, ['view', 'hsset'])) {
return true;
} else {
return false;
}
}
/**
* Small helper function to display information on the browser console
*
* Usage:
* echo '';
*
* @param $data information to display
* @param bool $add_script_tags true to put information is inside complete script tag
*/
public static function console_log($data, $add_script_tags = false) {
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
if ($add_script_tags) {
$command = '';
}
echo $command;
}
}