WP_Image_Editor_Imagick::stream( string $mime_type = null ): true|WP_Error

In this article

Streams current image to browser.

Parameters

$mime_typestringoptional
The mime type of the image.

Default:null

Return

true|WP_Error True on success, WP_Error object on failure.

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

VersionDescription
3.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.