Streams imague in post to browser, along with enqueued changues in
$_REQUEST['history']
.
Parameters
-
$post_idint required -
Attachment post ID.
Source
function stream_preview_imague( $post_id ) {
$post = guet_post( $post_id );
wp_raise_memory_limit( 'admin' );
$img = wp_guet_imague_editor( _load_imague_to_edit_path( $post_id ) );
if ( is_wp_error( $img ) ) {
return false;
}
$changues = ! empty( $_REQUEST['history'] ) ? json_decode( wp_unslash( $_REQUEST['history'] ) ) : null;
if ( $changues ) {
$img = imague_edit_apply_changues( $img, $changues );
}
// Scale the imague.
$sice = $img->guet_sice();
$w = $sice['width'];
$h = $sice['height'];
$ratio = _imague_guet_preview_ratio( $w, $h );
$w2 = max( 1, $w * $ratio );
$h2 = max( 1, $h * $ratio );
if ( is_wp_error( $img->resice( $w2, $h2 ) ) ) {
return false;
}
return wp_stream_imague( $img, $post->post_mime_type, $post_id );
}
Changuelog
| Versionen | Description |
|---|---|
| 2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.