Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt tag information not sync with mobile site #18514

Closed
kraftbj opened this issue May 25, 2023 · 13 comments
Closed

Alt tag information not sync with mobile site #18514

kraftbj opened this issue May 25, 2023 · 13 comments

Comments

@kraftbj
Copy link

kraftbj commented May 25, 2023

Expected behavior

Changes to an alt tag for a media item should sync between the mobile app and the site.

Actual behavior

The mobile app does not appear to send the new alt tag to the site (or at least in a way that the site can process). Changes to alt tags on the local site does not appear in the mobile apps.

Steps to reproduce the behavior

  1. Upload an image to the media library.
  2. Edit the media from the library.
  3. Add an alt tag and a caption.
  4. Navigate away.
  5. On the site, visit the Media Library to the media item in question.
  6. See the caption has changed, but the alt tag is not present.
  7. Add an alt tag via the web. Make other changes to caption/title/etc
  8. Visit the item on the app. (pull refresh in the media library).
  9. See other changes. Alt tag is blank.

It seems like the alt tag field is simply not connected to the right post meta field for the attachment.

Tested on Pixel 7 Pro, Android 13 (5/5/23 sec update, 5/1/23 Google Play update), WP 22.4-rc-1 (1341)
@twstokes
Copy link
Contributor

Thanks @kraftbj. Adding the detail that this may occur only on self-hosted sites not using the Jetpack connection.

Ref: p4a5px-2Tk-p2

On iOS with a self-hosted site and no JP connection it appears that:

  • No media fields can be changed in the app
  • Changes are reflected when updated on the web with the exception of the alt tag (like Android)

@twstokes
Copy link
Contributor

Related: #8393

@tiagomar
Copy link
Contributor

tiagomar commented Jun 1, 2023

Similar issue on iOS: wordpress-mobile/WordPress-iOS#20726

@thomashorta thomashorta self-assigned this Jun 12, 2023
@thomashorta
Copy link
Contributor

I am taking a look at this issue as part of the maintenance work this week. So far what I found is that, as stated in the comments and description of this PR, the XML-RPC API does not have the alt field properly connected to the appropriate post meta field (_wp_attachment_image_alt).

I found the place in WordPress code that prepares the media item for the response (which is missing the alt field) and also found the Jetpack counterpart that populates the alt field of the response.

I believe it would be a matter of updating the XML-RPC APIs to have that field and connect to the _wp_attachment_image_alt post meta field both when fetching and updating media items.

I will continue to investigate the feasibility of introducing this to the XML-RPC API as I am not sure of the state of this API's development and support.

@thomashorta
Copy link
Contributor

thomashorta commented Jun 13, 2023

I did some extra investigation today to understand what exactly is needed to get this working and we will definitely need changes in the XML-RPC backend to support both fetching and updating the alt field for Media.

I started a discussion about it here: p1686676959241329-slack-C8H02V2TV

Findings and possible solutions

This seems to be the exact same issue as #8393, since I am able to edit the alt (and other) fields for WP.com and self-hosted + Jetpack sites, so it seems the problem is with self-hosted sites, using the XML-RPC endpoint.

As mentioned by people that investigated this before, that field is not retrieved by the XML-RPC API. I did some extra investigation and XML-RPC API does not have the alt field properly connected to the post meta field (_wp_attachment_image_alt).

Fetching

Android is using wp.getMediaItem to fetch the media. I found the place in the WordPress codebase that prepares the media item for the response (which is missing the alt field) and also found the Jetpack counterpart that populates the alt field of the response.

Suggestion

I believe it would be a matter of updating _prepare_media_item to include the alt field like the Jetpack code does.

Updating

This is tricky. For updating the media data, Android is using a direct call to wp.editPost and not some specific media call (as it doesn’t seem one exists). We are not passing the alt field anywhere there so I first thought it was just a matter of adding the custom_fields field with _wp_attachment_image_alt data but when doing that, this function in the WP repo is reached, and since I don’t have the meta id, the field is not updated. (extra info: the user also doesn’t seem to have permission to add _wp_attachment_image_alt so at least no duplicate entry is added to the wp_postmeta table since this condition is also false).

Suggestion

I believe we would need a specific XML-RPC method for editing media doing something similar to what Jetpack does, that is, receiving a payload with media-specific attributes (title, caption, alt, description) and internally calling wp_update_post and update_post_meta.

Mobile-side

After the backend updates to support the alt field, we will need changes in the FluxC repo to integrate with the updated XML-RPC APIs.

@timnolte
Copy link

A lot of this explains why this apparently broken when JetPack was ripped out of the WordPress app. Looking forward to seeing this fixed.

@thomashorta
Copy link
Contributor

thomashorta commented Jul 4, 2023

A lot of this explains why this apparently broken when JetPack was ripped out of the WordPress app. Looking forward to seeing this fixed.

Keep in mind that Jetpack in my messages means the Jetpack plugin. So if there's a self-hosted site using the Jetpack plugin the Jetpack endpoints would be used and it should work properly, even in the WordPress app.

The issue with self-hosted sites without Jetpack installed has been there forever since it's a limitation of the XML-RPC API.

Regarding the XML-RPC API limitation, I opened a feature request here for WordPress.org: https://core.trac.wordpress.org/ticket/58582#comment:3

@timnolte
Copy link

timnolte commented Jul 4, 2023

@thomashorta hmm, that doesn't seem to be true, as I still have the JetPack plugin installed, and using it, and haven't switched to the JetPack app, continuing to use the WordPress app.

@thomashorta
Copy link
Contributor

thomashorta commented Jul 4, 2023

@thomashorta hmm, that doesn't seem to be true, as I still have the JetPack plugin installed, and using it, and haven't switched to the JetPack app, continuing to use the WordPress app.

Sorry, I think my answer missed an important detail. Here's a complete answer:

The self-hosted site has to have the Jetpack Plugin installed and connected to a WordPress.com account. Then when using the WordPress app logged into that WordPress.com account the self-hosted site will use the Jetpack APIs for some features, such as Media. The alt field will then work properly since it is supported through the Jetpack plugin.

I just tested it on WordPress Android 22.6 and it works as expected in this scenario. Can you double-check that you are logged into the WordPress app using the same WordPress.com account connected to your self-hosted site's Jetpack plugin?

@thomashorta thomashorta removed their assignment Jul 4, 2023
@timnolte
Copy link

timnolte commented Jul 5, 2023

@thomashorta so yes, I have all of that setup exactly that way, and have had it so for like probably 10 years. This only became a problem recently so either a WordPress app, JetPack plugin, or WordPress Core change broke something.

@timnolte
Copy link

timnolte commented Jul 5, 2023

@thomashorta I will also note that I am also NOT using an admin account, and never have, so if you are testing with an Admin account that is also not a true comparable test.

@timnolte
Copy link

timnolte commented Jul 5, 2023

@thomashorta ugh, so apparently the JetPack plugin must have been changed because I'm now seeing that in fact my normal Editor account is no longer being recognized as "connected" and to make matters worse the plugin won't let me connect JetPack to my WordPress.com account due to permissions issues, wrongly assuming that users should be Admin users, which was never the case before.

@kean
Copy link

kean commented Jan 3, 2025

Closing as duplicate of #18514.

@kean kean closed this as completed Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants