Skip to content

Block Library: Preserve text content in Media & Text/Image transforms#70220

Closed
Sukhendu2002 wants to merge 2 commits intoWordPress:trunkfrom
Sukhendu2002:fix/media-text-image-transform-preserve-content
Closed

Block Library: Preserve text content in Media & Text/Image transforms#70220
Sukhendu2002 wants to merge 2 commits intoWordPress:trunkfrom
Sukhendu2002:fix/media-text-image-transform-preserve-content

Conversation

@Sukhendu2002
Copy link
Contributor

@Sukhendu2002 Sukhendu2002 commented May 26, 2025

What?

Part of: #63635

This PR ensures content preservation when transforming between Media & Text and Image blocks in both directions:

  • Media & Text → Image: Text content from paragraphs and headings is preserved as the image caption
  • Image → Media & Text: Image caption is preserved as a paragraph block

Testing Instructions

Testing Media & Text to Image transformation

  • Insert a Media & Text block
  • Add an image and some text content
  • Transform the block to an Image block
  • Verify the text content appears as the image caption

Testing Image to Media & Text transformation

  • Insert an Image block
  • Add an image and a caption
  • Transform the block to a Media & Text block
  • Verify the caption appears as a paragraph in the text area

Screenshots or screencast

Media & Text → Image
Before

Screen.Recording.2025-05-26.at.6.56.16.PM.mov

After

Screen.Recording.2025-05-26.at.6.56.47.PM.mov

Image → Media & Text
Before

Screen.Recording.2025-05-26.at.6.58.03.PM.mov

After

Screen.Recording.2025-05-26.at.6.57.32.PM.mov

@Sukhendu2002 Sukhendu2002 changed the title Fix/media text image transform preserve content Block Library: Preserve text content in Media & Text/Image transforms May 26, 2025
@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review May 26, 2025 13:17
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Block] Media & Text Affects the Media & Text Block [Type] Bug An existing feature does not function as intended [Feature] Block Transforms Block transforms from one block to another labels May 27, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think the content of the Media & Text block is "content", not image caption.

Furthermore, #64540, which is similar to this PR, has already been approved, so let's merge that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Media & Text Affects the Media & Text Block [Feature] Block Transforms Block transforms from one block to another [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants