Summery Summery
Streams current image to browser.
Syntax Syntax
Parameters Parameters
- $mime_type
-
(Optional) The mime type of the image.
Default value: null
Return Return
(bool|WP_Error) True on success, WP_Error object on failure.
Source Source
File: wp-includes/class-wp-image-editor-imagick.php
list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );
try {
// Temporarily change format for stream.
$this->image->setImageFormat( strtoupper( $extension ) );
// Output stream of image content.
header( "Content-Type: $mime_type" );
print $this->image->getImageBlob();
// Reset image to original format.
$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
} catch ( Exception $e ) {
return new WP_Error( 'image_stream_error', $e->getMessage() );
}
return true;
}
Advertisement
Changelog Changelog
| Version | Description |
|---|---|
| 3.5.0 | Introduced. |