WP_Image_Editor_GD::stream()
Returns stream of current image.
Метод класса: WP_Image_Editor_GD{}
Хуков нет.
Возвращает
true|false
. True on success, false on failure.
Использование
$WP_Image_Editor_GD = new WP_Image_Editor_GD(); $WP_Image_Editor_GD->stream( $mime_type );
- $mime_type(строка)
- The mime type of the image.
По умолчанию: null
Список изменений
С версии 3.5.0 | Введена. |
Код WP_Image_Editor_GD::stream() WP Image Editor GD::stream WP 6.7.1
public function stream( $mime_type = null ) { list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); switch ( $mime_type ) { case 'image/png': header( 'Content-Type: image/png' ); return imagepng( $this->image ); case 'image/gif': header( 'Content-Type: image/gif' ); return imagegif( $this->image ); case 'image/webp': if ( function_exists( 'imagewebp' ) ) { header( 'Content-Type: image/webp' ); return imagewebp( $this->image, null, $this->get_quality() ); } else { // Fall back to JPEG. header( 'Content-Type: image/jpeg' ); return imagejpeg( $this->image, null, $this->get_quality() ); } case 'image/avif': if ( function_exists( 'imageavif' ) ) { header( 'Content-Type: image/avif' ); return imageavif( $this->image, null, $this->get_quality() ); } // Fall back to JPEG. default: header( 'Content-Type: image/jpeg' ); return imagejpeg( $this->image, null, $this->get_quality() ); } }