Make WordPress Core

#62934 closed enhancement (wontfix)

WordPress Embedded Block Shows Large Whitespace for Short Posts

Reported by: devansh2002's profile devansh2002 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Embeds Keywords: has-patch dev-feedback close
Focuses: Cc:

Description

On frontend if we have WordPress Embedded block with a post that has less content WordPress Embedded block has large whitespace at the bottom.

Steps to Reproduce

  1. Create a WordPress post with only a title and no content.
  2. Create a new post and add a WordPress Embed block.
  3. Embed the previously created post.
  4. Save and preview the post on the frontend.

https://i.ibb.co/5gLYJ7Md/Screenshot-2025-02-10-at-5-44-02-PM.png

Attachments (1)

embed-dynamic-height.webm (2.3 MB) - added by swissspidy 15 months ago.
Possible solution with changing the embed's height when opening the sharing modal

Change History (14)

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


15 months ago
#1

  • Keywords has-patch added

Fix embed block height calculation by removing unnecessary lower bound check.

Issue: On frontend if we have WordPress Embedded block with a post that has less content WordPress Embedded block has large whitespace at the bottom.

Trac ticket: https://core.trac.wordpress.org/ticket/62934

@devansh2002 commented on PR #8286:


15 months ago
#2

Before After
https://github.com/user-attachments/assets/656c3353-8353-4e48-8e8f-a1f948494e29 https://github.com/user-attachments/assets/826d4a3d-63c5-4f92-982b-205cdc281b01

#3 @swissspidy
15 months ago

  • Keywords needs-testing dev-feedback added

Thanks for your report and the PR.

This needs careful testing, as the 200px min height was a deliberate decision at the time.

We don't want to allow the embedded iframe to resize itself to have 0px (and make itself invisible).

Maybe a smaller minimum like 100px is ok, but we should not outright remove the limit.

#4 @devansh2002
15 months ago

@swissspidy
I agree with setting a minimum height.

I tested embedding both short and long content posts.
The embedded iframe height was around 139px, and on mobile (320px width) it was about 161px for short post.
Since, it was less than 200px the iframe was using 200px as height and hence the whitespace.

A minimum height of 100px seems reasonable.

#5 @audrasjb
15 months ago

  • Milestone changed from Awaiting Review to 6.8
  • Owner set to audrasjb
  • Status changed from new to accepted
  • Type changed from defect (bug) to enhancement
  • Version changed from trunk to 4.4

Introduced in [34903].

If it's only to ensure the embed has a minimal height I would have gone with a smaller value, like 20 or 50px, but 100px looks more that reasonable at a glance, given the fact thats this is probably an edge case.

I tested the patch and the edited PR looks good to me.

#6 @swissspidy
15 months ago

Now I recall why it was 200px minimum height: the sharing dialog needs enough space.

100px is too short, it cuts a lot off.

200px is just enough to display it properly, even when selecting the "HTML Embed" code option. Anything below 200px wouldn't be enough.

We might be able to add some CSS inside the iframe to improve styling if there's not enough space, but we don't control what's inside. So if it's an embed from an older WP version it won't work.

Given the edge case I am inclined to rather close this as a wontfix.

(Reminder, I wrote this code ~10years ago)

#7 @audrasjb
15 months ago

Ahhh yeah I missed the sharing dialog! 😱
That's a big edge case indeed. I agree it's safer to not change this given the wide adoption of embeds…

#8 @swissspidy
15 months ago

The iframe might resize though when opening the sharing dialog, I‘ll need to check that.

#9 @dhrumilk
15 months ago

I tested the patch and PR looks good to me.

@swissspidy
15 months ago

Possible solution with changing the embed's height when opening the sharing modal

#10 @swissspidy
15 months ago

  • Keywords needs-testing removed

The iframe might resize though when opening the sharing dialog, I‘ll need to check that.

Nope, it doesn't.

That would be an interesting thing to add, but requires a bigger change to the embed-template.js file. Then the behavior would be like in the video I just added.

But even with such a change we can't just drop the minimum right away, because you might be embedding a post from an older WordPress site without the embed-template change.

So leaning towards wontfix or maybelater.

#11 @audrasjb
15 months ago

  • Keywords close added
  • Milestone changed from 6.8 to Awaiting Review

Alright, thanks for the investigation @swissspidy.
Removing from the milestone for now, but yes, it's probably better to close it as wontfix.

#12 @audrasjb
15 months ago

  • Owner audrasjb deleted
  • Status changed from accepted to assigned

#13 @swissspidy
11 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.