Make WordPress Core

Opened 5 years ago

Last modified 4 weeks ago

#55200 new defect (bug)

Cannot add caption to images on mobile

Reported by: vincepettit Owned by:
Priority: normal Milestone: Future Release
Component: Media Version: 5.9
Severity: normal Keywords: has-screenshots has-patch early
Cc: Focuses: ui, administration

Description

On the mobile view of the admin section you cannot add ally text, captions, or descriptions to media uploads

Attachments (1)

6FEBC7D3-A101-4B70-BE6A-663EADC0978F.png (4.6 MB ) - added by vincepettit 4 years ago.
No options on mobile view (Safari - iPhone 13 Pro)

Change History (12)

#1 follow-up: @sabernhardt
4 years ago

  • Component GeneralMedia
  • Keywords reporter-feedback needs-screenshots added

Hi and welcome to Trac!

Could you add screenshots and/or specific instructions for how you tried to add these details?

I don't know if something is not loading properly for you, or if the interface for editing those details is simply too hard to find on mobile.

@vincepettit
4 years ago

No options on mobile view (Safari - iPhone 13 Pro)

#2 in reply to: ↑ 1 @vincepettit
4 years ago

Replying to sabernhardt:

Hi and welcome to Trac!

Could you add screenshots and/or specific instructions for how you tried to add these details?

I don't know if something is not loading properly for you, or if the interface for editing those details is simply too hard to find on mobile.

When adding / editing a post in mobile I go to the feature image section. Upload or choose an image but there is nowhere to add captions. The only way that it is possible is you upload in the media area outside of the post.

It seems that the CSS is hiding that part of the screen that is available on desktop.

#3 @sabernhardt
4 years ago

  • Keywords has-screenshots needs-patch added; reporter-feedback needs-screenshots removed

Thanks for clarification. That panel apparently remains hidden at certain sizes because selecting an image does not add the visible class.

@media only screen and (max-width: 640px), screen and (max-height: 400px) {
	.media-sidebar {
		bottom: 120%;
	}
	.media-sidebar.visible {
		bottom: 0;
	}
}

#4 @vincepettit
3 years ago

Any news on this update? It’s frustrating not being able to edit the captions when adding images.

This ticket was mentioned in PR #11864 on WordPress/wordpress-develop by @kraftbj.


3 months ago
#5

  • Keywords has-patch added; needs-patch removed

On mobile viewports (max-width 640px or max-height 400px), the media modal's .media-sidebar is positioned off-screen by the responsive CSS rule in media-views.css:

.media-sidebar { bottom: 120%; }
.media-sidebar.visible { bottom: 0; }

The .visible class is added in AttachmentsBrowser#createSingle() only when the current state's id is 'insert' (the "Insert into post" flow). Every other state that lets the user select a single attachment — featured image picker, replace image, gallery flows — leaves the sidebar parked off-screen, making the Alternative Text, Caption, and Description fields unreachable on narrow viewports.

This is the root cause behind the long-standing report in Trac #55200 ("Cannot add caption to images on mobile"), where comment 3 already identified the exact CSS but no patch was filed. The most user-visible impact is that authors setting a featured image from a mobile browser cannot add alt text or a caption without leaving the post editor and going to the Media Library.

This PR extends the allowlist in createSingle() to include the other selection flows that surface attachment metadata in the sidebar:

  • featured-image (Set featured image)
  • replace-image (Replace media inside Image Details)
  • gallery-edit (Edit Gallery)
  • gallery-library (Add to Gallery)

The dispose side already removes the class unconditionally, so the show/hide pairing stays balanced.

## Testing

  1. Open a post in the block editor on a viewport narrower than 640px (or use device emulation in DevTools).
  2. In the post sidebar, click Set featured image.
  3. Select an image from the Media Library.
  4. Before this patch: the right-hand "Attachment Details" panel (with Alternative Text, Caption, etc.) is positioned off-screen and unreachable.
  5. After this patch: the panel slides on-screen as it does in the "Insert into post" flow.

The same fix takes effect in the Replace Media flow and Gallery editing flows.

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for:

  • Locating the responsible code path (browser.js:761) and the CSS rule that hides the sidebar off-screen.
  • Searching Trac for prior reports, which surfaced #55200 and confirmed that comment 3 from sabernhardt had already diagnosed the root cause four years ago.

The bug was found by a human (encountered while trying to set alt text on a featured image from a mobile browser). Diagnosis used AI assistance to trace the responsible code and locate the existing Trac ticket. The fix itself is a small, targeted code change reviewed and tested manually by a human before submission.

#6 @kraftbj
3 months ago

  • Focuses ui added
  • Milestone Awaiting Review7.1

@westonruter commented on PR #11864:


3 months ago
#7

I just tried testing in Playground, and I can see that the modal for selecting the featured image shows the properties. But it's not seeming to show anything when the modal is open for another image, like for the Image block:

https://github.com/user-attachments/assets/40c6c1d2-97f5-4f3d-a6b6-ab1354fb0930

This ticket was mentioned in Slack in #core-test by huzaifaalmesbah. View the logs.


4 weeks ago

This ticket was mentioned in Slack in #core by adrianduffell. View the logs.


4 weeks ago

#10 @adrianduffell
4 weeks ago

  • Keywords early added
  • Milestone 7.1Future Release

This was discussed in today’s bug scrub. As we are deep in the 7.1 beta, I'll punt this.

Adding early to flag it for possible inclusion in 7.2.

#11 @pedrofigueroa1989
4 weeks ago

I have suggested a small change in the PR to include core blocks, too:
https://github.com/WordPress/wordpress-develop/pull/11864#discussion_r3643818474

Note: See TracTickets for help on using tickets.