WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Preserve caption when converting Image Block to Media & Text Block #22478

Open eyesofjeremy opened 4 years ago

eyesofjeremy commented 4 years ago

The Problem When converting an Image Block to a Media & Text block, a previously-written caption gets lost.

A Solution? The Media & Text block seems to have a semantically similar structure to the Image Block — there is an image, and a section of text. When converting from Image Block to Media & Text, it would be great if any image caption gets converted into a paragraph text block.

What about switching back? If switching from an image block preserves the caption, then logically switching to an Image Block from Media & Text should also preserve content. But suddenly it's more complicated, as the Media & Text could have headings and multiple paragraphs. Right now, that's also lost in a switch.

Since the Image caption is not designed to contain multiple blocks of content, perhaps the different blocks could be converted to plain text separated by a single space upon conversion. Or even a double space, which might not last when saving, but could help an editor switch back if they would like to.

This might not be ideal, but seems far better than losing ALL content. And in the case of a simple one-paragraph caption, one gets to switch back and forth without real loss of productivity.

Alternatives If the image caption were saved with the media upon switching, then it would be available upon switching back. But this seems more complex, and less intuitive, than keeping the content visible to the editor during a switch.

annezazu commented 4 years ago

Hey @eyesofjeremy! Thanks for reporting this. For anyone looking into this, I was able to replicate this experience using Gutenberg 8.1.0 and WordPress 5.4.1 with the Twenty Twenty theme.

As for the issue itself, I imagine part of the trouble here is that what one wants as the caption vs as the text in the Media & Text block will likely be different. For example, I might make my caption say "picture of me at the fair" but want that separated out from the Text portion where I might write a more long form description of my experience at the fair. With that said, I think you're right that the current experience feels like a loss of productivity potentially if someone wrote a caption for an image then converted the block. On the flip side, there are use cases where someone might have uploaded a few images, added captions, and then went to use the Media & Text block only to get annoyed that the captions were included in the text portion.

Tagging design folks in here to see what ideas they might have :)

yunjuc commented 4 years ago

The same thing happens when transforming Image block to Cover block, the caption is lost. While the use case might be different between Cover, Image and Media & Text, perhaps the caption can be preserved in the text section in other blocks and vice versa.

eyesofjeremy commented 4 years ago

Thanks @annezazu! I can imagine some cases where someone is not going to want the captions carried over from an image block to a Media & Text block, but it seems like a very minor inconvenience compared with losing content. But you bring up a good point — should the Media & Text also have a spot for a caption? Could be part of the block's Settings sidebar.

@yunjuc good point. @annezazu can you also label this issue w/ "[Feature] Block Conversion"? This seems appropriate. FWIW there's a comment on Issue 11473 which mentions this destructive transformation. Maybe this is just part of the larger discussion on how to handle conversion between blocks.

annezazu commented 4 years ago

@eyesofjeremy updated with that label - great thinking! I agree that this does seem to be tied into a larger conversation but it's important to see detailed issues like this to help bring the problem to life.

ellatrix commented 4 months ago

See also #14604