wp_xmlrpc_server::_prepare_media_item()
Prepares media item data for return in an XML-RPC object.
Метод класса: wp_xmlrpc_server{}
Хуки из метода
Возвращает
Массив
. The prepared media item data.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->_prepare_media_item( $media_item, $thumbnail_size );
- $media_item(WP_Post) (обязательный)
- The unprepared media item data.
- $thumbnail_size(строка)
- The image size to use for the thumbnail URL.
По умолчанию: 'thumbnail'
Код wp_xmlrpc_server::_prepare_media_item() wp xmlrpc server:: prepare media item WP 6.7.1
protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) { $_media_item = array( 'attachment_id' => (string) $media_item->ID, 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), 'parent' => $media_item->post_parent, 'link' => wp_get_attachment_url( $media_item->ID ), 'title' => $media_item->post_title, 'caption' => $media_item->post_excerpt, 'description' => $media_item->post_content, 'metadata' => wp_get_attachment_metadata( $media_item->ID ), 'type' => $media_item->post_mime_type, 'alt' => get_post_meta( $media_item->ID, '_wp_attachment_image_alt', true ), ); $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); if ( $thumbnail_src ) { $_media_item['thumbnail'] = $thumbnail_src[0]; } else { $_media_item['thumbnail'] = $_media_item['link']; } /** * Filters XML-RPC-prepared data for the given media item. * * @since 3.4.0 * * @param array $_media_item An array of media item data. * @param WP_Post $media_item Media item object. * @param string $thumbnail_size Image size. */ return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size ); }