mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-01 14:00:08 +02:00
Added hook in img,php before CImage is called, #123.
This commit is contained in:
@@ -997,6 +997,65 @@ EOD;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log verbose details to file
|
||||||
|
*/
|
||||||
|
if ($verboseFile) {
|
||||||
|
$img->setVerboseToFile("$cachePath/log.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook after img.php configuration and before processing with CImage
|
||||||
|
*/
|
||||||
|
$hookBeforeCImage = getConfig('hook_before_CImage', null);
|
||||||
|
|
||||||
|
if (is_callable($hookBeforeCImage)) {
|
||||||
|
verbose("hookBeforeCImage activated");
|
||||||
|
|
||||||
|
$allConfig = $hookBeforeCImage($img, array(
|
||||||
|
// Options for calculate dimensions
|
||||||
|
'newWidth' => $newWidth,
|
||||||
|
'newHeight' => $newHeight,
|
||||||
|
'aspectRatio' => $aspectRatio,
|
||||||
|
'keepRatio' => $keepRatio,
|
||||||
|
'cropToFit' => $cropToFit,
|
||||||
|
'fillToFit' => $fillToFit,
|
||||||
|
'crop' => $crop,
|
||||||
|
'area' => $area,
|
||||||
|
'upscale' => $upscale,
|
||||||
|
|
||||||
|
// Pre-processing, before resizing is done
|
||||||
|
'scale' => $scale,
|
||||||
|
'rotateBefore' => $rotateBefore,
|
||||||
|
'autoRotate' => $autoRotate,
|
||||||
|
|
||||||
|
// General processing options
|
||||||
|
'bgColor' => $bgColor,
|
||||||
|
|
||||||
|
// Post-processing, after resizing is done
|
||||||
|
'palette' => $palette,
|
||||||
|
'filters' => $filters,
|
||||||
|
'sharpen' => $sharpen,
|
||||||
|
'emboss' => $emboss,
|
||||||
|
'blur' => $blur,
|
||||||
|
'convolve' => $convolve,
|
||||||
|
'rotateAfter' => $rotateAfter,
|
||||||
|
|
||||||
|
// Output format
|
||||||
|
'outputFormat' => $outputFormat,
|
||||||
|
'dpr' => $dpr,
|
||||||
|
|
||||||
|
// Other
|
||||||
|
'postProcessing' => $postProcessing,
|
||||||
|
));
|
||||||
|
verbose(print_r($allConfig, 1));
|
||||||
|
extract($allConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display image if verbose mode
|
* Display image if verbose mode
|
||||||
*/
|
*/
|
||||||
@@ -1034,15 +1093,6 @@ EOD;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log verbose details to file
|
|
||||||
*/
|
|
||||||
if ($verboseFile) {
|
|
||||||
$img->setVerboseToFile("$cachePath/log.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load, process and output the image
|
* Load, process and output the image
|
||||||
*/
|
*/
|
||||||
|
@@ -122,6 +122,24 @@ return array(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function (hook) can be called after img.php has processed all
|
||||||
|
* configuration options and before processing the image using CImage.
|
||||||
|
* The function receives the $img variabel and an array with the
|
||||||
|
* majority of current settings.
|
||||||
|
*
|
||||||
|
* Default value:
|
||||||
|
* hook_before_CImage: null
|
||||||
|
*/
|
||||||
|
/*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
|
||||||
|
if ($allConfig['newWidth'] > 10) {
|
||||||
|
$allConfig['newWidth'] *= 2;
|
||||||
|
}
|
||||||
|
return $allConfig;
|
||||||
|
},*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name representing a dummy image which is automatically created
|
* The name representing a dummy image which is automatically created
|
||||||
* and stored at the defined path. The dummy image can then be used
|
* and stored at the defined path. The dummy image can then be used
|
||||||
|
Reference in New Issue
Block a user