public function TestProcessorFailedGreenPNG::applyToImage in Image Optimize (or ImageAPI Optimize) 8.2
Same name and namespace in other branches
- 8.3 tests/module/imageapi_optimize_module_test/src/Plugin/ImageAPIOptimizeProcessor/TestProcessorFailedGreenPNG.php \Drupal\imageapi_optimize_module_test\Plugin\ImageAPIOptimizeProcessor\TestProcessorFailedGreenPNG::applyToImage()
- 4.x tests/module/imageapi_optimize_module_test/src/Plugin/ImageAPIOptimizeProcessor/TestProcessorFailedGreenPNG.php \Drupal\imageapi_optimize_module_test\Plugin\ImageAPIOptimizeProcessor\TestProcessorFailedGreenPNG::applyToImage()
Apply this image optimize processor to the given image.
Image processors should modify the file in-place or overwrite the file on disk with an optimized version.
Parameters
string $image_uri: Original image file URI.
Return value
bool TRUE if an optimized image was generated, or FALSE if the image could not be optimized.
Overrides ImageAPIOptimizeProcessorInterface::applyToImage
File
- tests/
module/ imageapi_optimize_module_test/ src/ Plugin/ ImageAPIOptimizeProcessor/ TestProcessorFailedGreenPNG.php, line 21
Class
- TestProcessorFailedGreenPNG
- Optimizes an image by making it a 1x1 pixel green PNG, but then failing.
Namespace
Drupal\imageapi_optimize_module_test\Plugin\ImageAPIOptimizeProcessorCode
public function applyToImage($image_uri) {
// Change the file to a green 1x1 PNG.
file_put_contents($image_uri, base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=='));
// Fail even though we changed the file.
return FALSE;
}