#58582 closed defect (bug) (fixed)
XML-RPC API: Add alt field support
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.4 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | XML-RPC | Keywords: | has-patch dev-reviewed has-unit-tests commit |
| Focuses: | accessibility | Cc: |
Description
Currently, the wp.getMediaItem (codex) method of the XML-RPC API does not retrieve the alt field associated with the media item.
Updating MediaItems through the XML-RPC API is also done directly by the Posts API, more specifically through wp.editPost (codex), which also doesn't support an alt field. This makes sense, as this API is more generic, but at the same time, there are no specific updateMedia methods in the Media API.
I did some investigation and the XML-RPC Media API does not have the alt field properly connected to the post meta field (_wp_attachment_image_alt) when preparing the media, which holds the alt field information for attachments/media and is used here for instance.
Would it be possible to add support to the alt field both when fetching and when updating Media items through the XML-RPC API?
Suggestion for fetching
I believe adding something like this to _prepare_media_item would work:
'alt' => get_post_meta( $media_item->ID, '_wp_attachment_image_alt', true ),
Suggestion for updating
I'm not sure about this one, but I think a new method in the Media API would be needed (e.g.: wp.updateMediaItem) to properly manipulate a specific input struct and call the Post update functions internally.
Change History (25)
This ticket was mentioned in Slack in #mobile by thomashorta. View the logs.
2 years ago
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
2 years ago
#6
@
2 years ago
- Keywords needs-patch added
- Owner set to joedolson
- Status changed from new to accepted
- Type changed from feature request to defect (bug)
We can't support good accessibility if some of our remote methods don't make it possible, so I'd actually consider this a significant bug, rather than a feature request. It's going to impact any XML RPC clients. As much as that's not the primary mechanism for editing content remotely anymore, this prevents best practices for any client still using XML RPC.
I'm not quite ready to milestone this for 6.4, because I'm not personally very familiar with the XML RPC apis, but I'm going to take ownership of it to do some research.
This is something where I wish we could tag multiple components; this is also a Media issue.
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
2 years ago
#8
@
2 years ago
- Milestone changed from Awaiting Review to 6.4
Discussed in accessibility bug scrub, and we think that this is important to investigate and try to get fixed.
This ticket was mentioned in PR #5084 on WordPress/wordpress-develop by steveerdelyi.
2 years ago
#9
- Keywords has-patch added; needs-patch removed
Updated _prepare_media_item to include user-provided attachment alt text
Add alt text to _premare_media_item in class-wp-xmlrpc-server.php
Trac ticket: https://core.trac.wordpress.org/ticket/58582
props: thomashorta, jivygraphics
@mukesh27 commented on PR #5084:
2 years ago
#10
Question: We already have the xmlrpc_prepare_media_item filter at the end of the function, so if anyone wants any additional data, they can extend it. Therefore, why do we need to add it? I'm curious to know the answer.
#11
@
2 years ago
- Keywords needs-testing added
- Type changed from defect (bug) to enhancement
- Version 6.3 deleted
@stephenerdelyi commented on PR #5084:
2 years ago
#13
I think it's important for accessibility purposes that this is included by default. I would expect a media object to always contain an alt without additional modifications required 🙂
steveerdelyi commented on PR #5084:
2 years ago
#14
Hey @mukeshpanchal27 what do you think, should we merge this in or would you still prefer to require manual registration for alts delivered via XMLRPC?
@mukesh27 commented on PR #5084:
2 years ago
#15
Thank you, @steveerdelyi. I would appreciate incorporating these changes into the core itself, eliminating the need for using a filter. Thank you.
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
2 years ago
@stephenerdelyi commented on PR #5084:
2 years ago
#19
Hi @joedolson , just looking to see when you might have a moment to review this? Thanks!
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
2 years ago
#22
@
2 years ago
The original issue calls for a new updateMedia method, but that would be only marginally different from the existing editPost method, since passing custom fields via that method is already supported.
In the interest of getting this fix done in 6.4, I'm going to commit the existing PR - adding alt text to the output, which fixes a bug.
Adding a new method, however, would be an enhancement; I'll open a new ticket to track that after I finish this.
@joedolson commented on PR #5084:
2 years ago
#24
In r56637
@markoheijnen, I see you are the maintainer for the XML-RPC component. Do you think this request is feasible?