Skip to content
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

Report error when URLs can't be embedded and don't generate a fallback #10407

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

notnownikki
Copy link
Member

Description

Trying to embed some WordPress URLs that can't be embedded will result in a blank preview, rather than an error saying that the URL couldn't be embedded.

This is because oEmbed sometimes doesn't do maybe_make_link and returns a response with a data.status of 404 instead.

This change accounts for that.

How has this been tested?

Try to embed https://wordpress.org/gutenberg/handbook/
You should see the error saying that it can't be embedded.

Types of changes

Bug fix

@notnownikki notnownikki requested a review from a team October 8, 2018 14:44
@notnownikki notnownikki modified the milestones: 4.0, 4.1 Oct 8, 2018
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

This looks good and works a charm!

The only nitpick I'd have is that there a mixing of types (preview can be a boolean or an object, cannotEmbed can be a string or a boolean), which could cause some issues down the line if someone else tries to use those variables thinking they're one type when they're another. I think we've had this bite us when trying to optionally set attributes on elements.

@notnownikki notnownikki merged commit 49f8f2b into master Oct 10, 2018
@youknowriad youknowriad deleted the fix/wordpress-urls-that-dont-get-fallback branch October 10, 2018 07:57
@gziolo gziolo modified the milestones: 4.1, 4.0 Oct 10, 2018
@mtias mtias added the [Block] Embed Affects the Embed Block label Oct 10, 2018
@@ -412,8 +414,12 @@ function getEmbedBlockSettings( { title, description, icon, category = 'embed',
const preview = url && getEmbedPreview( url );
const previewIsFallback = url && isPreviewEmbedFallback( url );
const fetching = undefined !== url && isRequestingEmbedPreview( url );
// Some WordPress URLs that can't be embedded will cause the API to return
Copy link
Member

Choose a reason for hiding this comment

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

Should this be normalized at the REST API / data store, rather than delegating the responsibility to the consuming UI component to handle ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Embed Affects the Embed Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants