mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-01 14:37:31 +00:00
XML-RPC: Add alt attribute value to media item API.
Add alt text to the `wp.getMediaItem` method in the XML-RPC API. Allows users to fetch alt text as a first-class member of a media object. Props thomashorta, joedolson, jivygraphics, stephenerdelyi, mukesh27, whyisjake. Fixes #58582. git-svn-id: https://develop.svn.wordpress.org/trunk@56637 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
107c730164
commit
5b79a4cd49
@ -1067,6 +1067,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'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 );
|
||||
|
||||
@ -25,6 +25,7 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
$this->attachment_id = $this->_make_attachment( $upload, self::$post_id );
|
||||
$this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
|
||||
update_post_meta( $this->attachment_id, '_wp_attachment_image_alt', 'Waffle has alt text' );
|
||||
|
||||
set_post_thumbnail( self::$post_id, $this->attachment_id );
|
||||
}
|
||||
@ -60,6 +61,7 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertIsString( $result['link'] );
|
||||
$this->assertIsString( $result['thumbnail'] );
|
||||
$this->assertIsArray( $result['metadata'] );
|
||||
$this->assertIsString( $result['alt'] );
|
||||
|
||||
// Check expected values.
|
||||
$this->assertStringMatchesFormat( '%d', $result['attachment_id'] );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user