wp_xmlrpc_server::_prepare_media_item( object $media_item, string $thumbnail_size = 'thumbnail' )

Prepares media item data for return in an XML-RPC object.


Description Description


Parameters Parameters

$media_item

(object) (Required) The unprepared media item data.

$thumbnail_size

(string) (Optional) The image size to use for the thumbnail URL.

Default value: 'thumbnail'


Top ↑

Return Return

(array) The prepared media item data.


Top ↑

Source Source

File: wp-includes/class-wp-xmlrpc-server.php

	protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
		$_media_item = array(
			'attachment_id'    => strval( $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,
		);

		$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 object $media_item     Media item object.
		 * @param string $thumbnail_size Image size.
		 */
		return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.