Streams current image to browser.
Parameters
$mime_type
stringoptional- The mime type of the image.
Default:
null
Source
* @param Imagick $image
* @param string $filename The destination filename or stream URL.
* @return true|WP_Error
*/
private function write_image( $image, $filename ) {
if ( wp_is_stream( $filename ) ) {
/*
* Due to reports of issues with streams with `Imagick::writeImageFile()` and `Imagick::writeImage()`, copies the blob instead.
* Checks for exact type due to: https://www.php.net/manual/en/function.file-put-contents.php
*/
if ( file_put_contents( $filename, $image->getImageBlob() ) === false ) {
return new WP_Error(
'image_save_error',
sprintf(
/* translators: %s: PHP function name. */
__( '%s failed while writing image to stream.' ),
'<code>file_put_contents()</code>'
),
$filename
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.