get_media_items
函数
get_media_items ( $post_id, $errors )
- 参数
-
-
(int)
$post_id
Post ID.- Required: 是
-
(array)
$errors
Errors for attachment, if any.- Required: 是
-
(int)
- 返回值
-
- (string) HTML content for media items of post gallery.
- 定义位置
-
-
wp-admin/includes/media.php
, line 1517
-
wp-admin/includes/media.php
- 引入
- 2.5.0
- 弃用
- –
Retrieves HTML for media items of post gallery.
The HTML markup retrieved will be created for the progress of SWF Upload
component. Will also create link for showing and hiding the form to modify
the image attachment.
function get_media_items( $post_id, $errors ) { $attachments = array(); if ( $post_id ) { $post = get_post( $post_id ); if ( $post && 'attachment' === $post->post_type ) { $attachments = array( $post->ID => $post ); } else { $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC', ) ); } } else { if ( is_array( $GLOBALS['wp_the_query']->posts ) ) { foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) { $attachments[ $attachment->ID ] = $attachment; } } } $output = ''; foreach ( (array) $attachments as $id => $attachment ) { if ( 'trash' === $attachment->post_status ) { continue; } $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ); if ( $item ) { $output .= "n"; } } return $output; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。