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.
Contents
Parameters
- $mime_type
(string)(Optional)The mime type of the image.
Default value: null
Return
(true|WP_Error) True on success, WP_Error object on failure.
Source
File: wp-includes/class-wp-image-editor.php
abstract public function stream( $mime_type = null );
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |