-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
WIP: Add caption to post featured image #46883
Conversation
Size Change: +5.1 kB (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in c6dedbd. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4260628325
|
The PR is ready for early feedback about the user experience when selecting between the custom caption and media library caption. |
Oh that's an interesting one, thanks for taking a stab. So just to be sure I'm getting this right, not only does this PR enable the caption button for the post featured image block, but it allows you to choose between the caption stored for the media item, or using a custom one, is that right? This actually surfaces a bit of a disconnect we have with captions, including the one we have for images. There's a caption field in the database, but the caption feature is not connected with it at all. Should it be, in both cases? I.e. when you add a caption, it also saves it for the image? (My instinct is probably not, especially since the disconnected version is out there. But I feel like it's an important question to ask!) Same unknown around the other fields, title, description, alt text. Caption and alt text feel like the odd ones out, and almost anachronistic in the block editor world. So approaching it from the opposite end: if we were to rebuild the media library today, from scratch, would we add a field called "Caption"? I'm not suggesting retiring those fields, but would we build such a media library and have it save alt text and captions separately from the block content? Either answer seems like it could inform next steps on this one, and both feel relevant to noodle on for this one. What do you think? |
Yes that is correct. Image block: I think both the caption, alt and title attribute can be situational and that they should not be saved to the image data in the media library. If you upload an image and its data is imported and saved to the database, or if you add a caption in the media library, then changing the caption in the block editor should not replace the text. |
With what we have today, the caption won't be visible the majority of the editing experience — only if you add the Post Featured Image block to the block editor. When we have content editing within the Site Editor, it'll be more front-and-center.
I think the caption should be tied to the featured image, not the block (just like the image is the featured image). If I edit the featured image, the post's featured image is updated. Its caption should work the same: if I edit the featured image's caption, it is consistent wherever the post featured image is leveraged. Also, I'm cool with making the button a show/hide functionality, rather than an add/remove. I'd say the same for the Image block as well. Having a caption — and whether or not it is visible — should be treated differently.
Yea, I agree. |
The existing caption feature, ignoring this PR, does not save the caption to the image. I believe it is too late to make it save to the image since there are already images placed with custom captions. "The caption wont be visible... unless you are in the block editor" Edit: I mentioned that the issue had a discussion about image credit in Germany, but it was actually a discussion in the WordPress Slack channel that referenced the issue. An account is needed to read it: https://wordpress.slack.com/archives/C015GUFFC00/p1672557641127699?thread_ts=1672500070.405439&cid=C015GUFFC00 |
Agreed.
You can't see the actual post's featured image caption in the Site Editor, it's a placeholder. Once we have content-editing you will be able to see it. With this PR the only way to actually see your caption, is to use it within the Block Editor, yea?
Then perhaps we make it work 100% like the image block's caption? Why not make it editable? |
It depends where in the Site Editor. If it is in the Site Editor and inside a query loop, and the featured image has a media library caption, the media library caption can be toggled on and off. (Forgive my test content I was testing the post excerpt block) In a post template, without the query loop, it can be toggled on and off, it will display the media library caption on the front depending on the featured image that is used on that post. |
I did not understand. Can you be more specific? It is already editable when in the block editor, outside a query.
Currently without this PR, in the image block, you can't choose to display the media library caption if you have done one of the following: |
Let's maybe back up a little. Should the caption work the same as other media captions do?I think yes. That means you can edit the caption via RichText component, if it's turned on — regardless of if it comes from the Media Library caption field or not. Example: If I press "Remove caption" then the caption is removed. If I press "Add caption" then I can type in a caption. The toolbar item for caption is always there, not dependent if there's a caption in the Media Library entry. Editing the captionAll that is assuming you see the caption (to edit it like the Image block's caption). If you add the post featured image block to a template (likely), you'll see the placeholder caption (as you should). There's no relative content templates; everything's a placeholder. In Query loop, you can toggle the caption on — but can't edit it. There's actually not a way to edit the caption as-is, unless you go back to the Media Library — probably via WP admin. I would expect that I could click on the caption in this context (when it's not a placeholder) to edit it — same as I can for all other media blocks. Media Library v. Custom CaptionsI don't think we need to separate "Media Library caption" and "Custom caption", but just like the Image block, use the Media Library caption, unless it has been edited. We should push for one-to-one experiences for blocks within the Post and Site Editors, and like-blocks as well. |
Doing that you still can't choose to display the media library caption if you have done one of the following: But do you see a way to edit the caption for individual posts inside a query without saving the caption to the image, which I thought we agreed we couldn't do? |
This round I have assumed that with "make it editable" you meant make the media library caption editable and save the updated text as the block's caption attribute. It would have helped me if the suggestion had been more specific. I spent more hours on this than I would like but I was not able to solve it and make it work exactly like for the other media blocks. 😞 One of the problems is making the media library caption show by default without clicking the caption button. |
Closing this experiment in favor of a simpler solution. |
What?
This is an experiment for #40946.
Why?
The post featured image block does not have support for captions, which makes it inconsistent with the image block.
Many sites have existing image captions stored in the media library. Users who are switching from classic editing to using blocks can not easily reuse this data. This makes it difficult for users who are required to show image credits to switch to using blocks.
How?
The plan is to try something like the following:
Video
Single post featured image with caption:
caption.mov
Longer video with more block settings:
https://user-images.githubusercontent.com/7422055/221135017-3e3ed808-ed4e-4708-98b7-f37461fdb1f7.mov