wp_image_editor
函数
wp_image_editor ( $post_id, $msg = false )
- 参数
-
-
(int)
$post_id
Attachment post ID.- Required: 是
-
(false|object)
$msg
Optional. Message to display for image editor updates or errors. Default false.- Required: 否
- Default: false
-
(int)
- 定义位置
-
-
wp-admin/includes/image-edit.php
, line 18
-
wp-admin/includes/image-edit.php
- 引入
- 2.9.0
- 弃用
- –
加载WP图像编辑界面。
function wp_image_editor( $post_id, $msg = false ) {
$nonce = wp_create_nonce( "image_editor-$post_id" );
$meta = wp_get_attachment_metadata( $post_id );
$thumb = image_get_intermediate_size( $post_id, 'thumbnail' );
$sub_sizes = isset( $meta['sizes'] ) && is_array( $meta['sizes'] );
$note = '';
if ( isset( $meta['width'], $meta['height'] ) ) {
$big = max( $meta['width'], $meta['height'] );
} else {
die( __( 'Image data does not exist. Please re-upload the image.' ) );
}
$sizer = $big > 400 ? 400 / $big : 1;
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$can_restore = false;
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
}
if ( $msg ) {
if ( isset( $msg->error ) ) {
$note = "$msg->error";
} elseif ( isset( $msg->msg ) ) {
$note = "$msg->msg";
}
}
$edit_custom_sizes = false;
/**
* Filters whether custom sizes are available options for image editing.
*
* @since 6.0.0
*
* @param bool|string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names.
*/
$edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes );
?>
, this )" class="imgedit-crop button disabled" disabled>
get_post_mime_type( $post_id ),
'methods' => array( 'rotate' ),
)
) ) {
$note_no_rotate = '';
?>
, this)">
, this)">
<?php } else {
$note_no_rotate = '' . __( 'Image rotation is not supported by your web host.' ) . '';
?>
, this)" class="imgedit-flipv button">
, this)" class="imgedit-fliph button">
, this)" class="imgedit-undo button disabled" disabled>
, this)" class="imgedit-redo button disabled" disabled>
)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="" />
<?php printf(
/* translators: %s: Image width and height in pixels. */
__( 'Original dimensions %s' ),
'' . $meta['width'] . ' × ' . $meta['height'] . ''
);
?>
×
!
, 'scale')" class="button button-primary" value="" />
, 'restore')" class="button button-primary" value="" />
:
×
$size ) {
if ( array_key_exists( $size, $meta['sizes'] ) ) {
if ( 'thumbnail' === $size ) {
continue;
}
?>
<?php }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。