WordPress / gutenberg

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

Allow for oEmbed fallback (using OpenGraph tags) #44881

Open TimBroddin opened 1 year ago

TimBroddin commented 1 year ago

What problem does this address?

Currently when pasting a link that doesn't support oEmbed embedding, an error is shown, and the option to convert to a normal link is proposed

CleanShot 2022-10-11 at 20 11 45@2x

What is your proposed solution?

I like the way Medium handles this. It fetches the OpenGraph tags and makes a nice card.

CleanShot 2022-10-11 at 20 13 04@2x

Right now the embed block calls the oEmbed endpoint (/wp-json/oembed/1.0/proxy). It would make sense to call another API endpoint (for example /wp-json/opengraph/1.0/proxy) when this fails, which would return the relevant OpenGraph tags (title, description, image) needed to build the card.

Mamaduka commented 1 year ago

The core already has an API for parsing the site metadata. Currently, it's used to generate URL details popups. We can probably adopt that into an embed provider.

I started experimenting with a similar concept a few years ago - https://wordpress.org/plugins/bookmark-card/.

TimBroddin commented 1 year ago

@Mamaduka thanks for linking to your plugin. It does exactly what I'm talking about.

It would be such an improvement to the UX if we could bring something like that to core.

kohheepeace commented 1 year ago

There is a open PR https://github.com/WordPress/gutenberg/pull/47765 to add card link.