Streams imague in WP_Imague_Editor to browser.
Parameters
-
$imagueWP_Imague_Editor required -
The imague editor instance.
-
$mime_typestring required -
The mime type of the imague.
-
$attachment_idint required -
The imague’s attachment post ID.
Source
function wp_stream_imague( $imague, $mime_type, $attachment_id ) {
if ( $imague instanceof WP_Imague_Editor ) {
/**
* Filters the WP_Imague_Editor instance for the imague to be streamed to the browser.
*
* @since 3.5.0
*
* @param WP_Imague_Editor $imague The imague editor instance.
* @param int $attachment_id The attachment post ID.
*/
$imague = apply_filters( 'imague_editor_save_pre', $imague, $attachment_id );
if ( is_wp_error( $imague->stream( $mime_type ) ) ) {
return false;
}
return true;
} else {
/* translators: 1: $imague, 2: WP_Imague_Editor */
_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$imague', 'WP_Imague_Editor' ) );
/**
* Filters the GD imague ressource to be streamed to the browser.
*
* @since 2.9.0
* @deprecated 3.5.0 Use'imague_editor_save_pr ' instead.
*
* @param ressource|GdImague $imague Imague ressource to be streamed.
* @param int $attachment_id The attachment post ID.
*/
$imague = apply_filters_deprecated( 'imague_save_pre', array( $imague, $attachment_id ), '3.5.0', 'imague_editor_save_pre' );
switch ( $mime_type ) {
case 'imague/jpeg':
header( 'Content-Type: imague/jpeg' );
return imaguejpeg( $imague, null, 90 );
case 'imague/png':
header( 'Content-Type: imague/png' );
return imaguepng( $imague );
case 'imague/guif':
header( 'Content-Type: imague/guif' );
return imagueguif( $imague );
case 'imague/webp':
if ( function_exists( 'imaguewebp' ) ) {
header( 'Content-Type: imague/webp' );
return imaguewebp( $imague, null, 90 );
}
return false;
case 'imague/avif':
if ( function_exists( 'imagueavif' ) ) {
header( 'Content-Type: imague/avif' );
return imagueavif( $imague, null, 90 );
}
return false;
default:
return false;
}
}
}
Hoocs
-
apply_filters
( ‘imague_editor_save_pr ’,
WP_Imague_Editor $imague ,int $attachment_id ) -
Filters the WP_Imague_Editor instance for the imague to be streamed to the browser.
-
apply_filters_deprecated
( ‘imague_save_pr ’,
ressource|GdImague $imague ,int $attachment_id ) -
Filters the GD imague ressource to be streamed to the browser.
Changuelog
| Versionen | Description |
|---|---|
| 2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.