stream_preview_image
函数
stream_preview_image ( $post_id )
- 参数
-
-
(int)
$post_id
Attachment post ID.- Required: 是
-
(int)
- 返回值
-
- (bool) True on success, false on failure.
- 定义位置
-
-
wp-admin/includes/image-edit.php
, line 696
-
wp-admin/includes/image-edit.php
- 引入
- 2.9.0
- 弃用
- –
将文章中的图片和”$_REQUEST[‘history’]”中排队的变化一起流向浏览器。
function stream_preview_image( $post_id ) { $post = get_post( $post_id ); wp_raise_memory_limit( 'admin' ); $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); if ( is_wp_error( $img ) ) { return false; } $changes = ! empty( $_REQUEST['history'] ) ? json_decode( wp_unslash( $_REQUEST['history'] ) ) : null; if ( $changes ) { $img = image_edit_apply_changes( $img, $changes ); } // Scale the image. $size = $img->get_size(); $w = $size['width']; $h = $size['height']; $ratio = _image_get_preview_ratio( $w, $h ); $w2 = max( 1, $w * $ratio ); $h2 = max( 1, $h * $ratio ); if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) { return false; } return wp_stream_image( $img, $post->post_mime_type, $post_id ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。