WP_Image_Editor::stream() WordPress Method

The WP_Image_Editor::stream() function is used to display an image directly to the browser. This is useful for images that are generated on the fly and don't need to be saved to the server. To use this function, specify the image format you want to use and the image quality (0-100). You can also specify whether you want the image to be cropped or resized. Finally, call the stream() function with the path to the image. For example, to display a generated image in JPEG format with a quality of 80%, you would use the following code: $editor = wp_get_image_editor( 'generated-image.jpg' ); if ( ! is_wp_error( $editor ) ) { $editor->set_quality( 80 ); $editor->stream(); }

WP_Image_Editor::stream( string $mime_type = null ) #

Streams current image to browser.


Parameters

$mime_type

(string)(Optional)The mime type of the image.

Default value: null


Top ↑

Return

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


Top ↑

Source

File: wp-includes/class-wp-image-editor.php

	abstract public function stream( $mime_type = null );

Top ↑

Changelog

Changelog
VersionDescription
3.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.