You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Embed for Medium posts doesn't preview in admin #7357
Describe the bug
When embedding a medium.com post in the editor, the preview in the admin screen is invisible, although the "Edit HTML" view shows content and it also works on front-end view.
Expected behavior
... that I see the preview of the embedded article in my admin screen.
Screenshots
Video: http://recordit.co/wS2LI2pFNf (don't worry about duplicate displays on the front-end, I didn't delete the previously added embed blocks until I noticed that there is a bug)
Stock WordPress + Gutenberg can't embed Medium posts, I'm guessing that there's a plugin that handles Medium posts with a shortcode. If so, #9734 would have fixed that, and will be in the 4.0 release.
That's interesting. It's embedded in the front end, just not visible in the editor. I can even look at the htm in the editor it's just a white space otherwise. Screenshot is from this published post:
And Here is what it looks like in the Editor a white space in an embed block
When using the HTML View it looks like this:
It looks to me like a default Gutenberg Embed block, doesn't it?
Ah, that's exactly the same symptom as when an embed is handled by a shortcode, which #9734 fixes :)
What happens is that oEmbed can't embed the URL with any of its default providers, so it tries to do it with a shortcode. The shortcode enqueues scripts, which show up fine on the front end because that loads all the scripts, but the embed preview only receives the HTML, and not the enqueued scripts. So if you inspect the preview, you'd see an iframe with some HTML in it, but the scripts that transform it into the embedded post aren't there.
The Pinterest embed provided by Jetpack did the same. 4.0 should be a rocking release :)
I'm testing this with 4.0 and is funny how it behaves:
If we add the Medium URL to the embed block, we get a Sorry, we could not embed that content. message , however if we paste that URL on a shortcode block we get a View story at Medium.com link in the front-end that redirects to the article:
What are you using to add support for embedding Medium? This isn't supported by WordPress core.
If you're using Jetpack, I'm seeing something different with the latest Jetpack and G4.0. The embed block tries to preview Medium, but there are javascript errors coming from the Medium javascript, which is why the preview fails. Also, it doesn't work in the classic editor either, so this might not a Gutenberg issue.
@iamgabrielma That would be great, just so we can keep track of things. I'm not sure whether or how it can be fixed though. The reason why it works is simple I think: the shortcode block passes the string to do_shortcode(), which obviously doesn't do anything. But later on, the embed handler parses the URL and turns it into an embed.
Activity
swissspidy commentedon Sep 3, 2018
I thought Medium has disabled their oEmbed API some time ago…?
bph commentedon Sep 8, 2018
@mtias what kind of test are you looking for?
here is another screen recording with Firefox:
http://recordit.co/abUl42T1xB
notnownikki commentedon Oct 4, 2018
Stock WordPress + Gutenberg can't embed Medium posts, I'm guessing that there's a plugin that handles Medium posts with a shortcode. If so, #9734 would have fixed that, and will be in the 4.0 release.
bph commentedon Oct 4, 2018
That's interesting. It's embedded in the front end, just not visible in the editor. I can even look at the htm in the editor it's just a white space otherwise. Screenshot is from this published post:

And Here is what it looks like in the Editor a white space in an embed block

When using the HTML View it looks like this:

It looks to me like a default Gutenberg Embed block, doesn't it?
notnownikki commentedon Oct 4, 2018
Ah, that's exactly the same symptom as when an embed is handled by a shortcode, which #9734 fixes :)
What happens is that oEmbed can't embed the URL with any of its default providers, so it tries to do it with a shortcode. The shortcode enqueues scripts, which show up fine on the front end because that loads all the scripts, but the embed preview only receives the HTML, and not the enqueued scripts. So if you inspect the preview, you'd see an iframe with some HTML in it, but the scripts that transform it into the embedded post aren't there.
The Pinterest embed provided by Jetpack did the same. 4.0 should be a rocking release :)
bph commentedon Oct 4, 2018
Woohoo! You might have explained this to me before, but I only got it now. Thanks for the patience.
notnownikki commentedon Oct 4, 2018
My pleasure! Let's leave this one open until it's been tested with 4.0
iamgabrielma commentedon Oct 18, 2018
I'm testing this with 4.0 and is funny how it behaves:
If we add the Medium URL to the embed block, we get a
Sorry, we could not embed that content.message , however if we paste that URL on a shortcode block we get aView story at Medium.comlink in the front-end that redirects to the article:Editor:

Front end:

swissspidy commentedon Oct 18, 2018
A shortcode block expects some kind of shortcode, not just a URL... 🤔
notnownikki commentedon Oct 18, 2018
What are you using to add support for embedding Medium? This isn't supported by WordPress core.
If you're using Jetpack, I'm seeing something different with the latest Jetpack and G4.0. The embed block tries to preview Medium, but there are javascript errors coming from the Medium javascript, which is why the preview fails. Also, it doesn't work in the classic editor either, so this might not a Gutenberg issue.
iamgabrielma commentedon Oct 19, 2018
Should I open a new issue regarding the validation of the shortcode input? Is not really related to this and would make more sense separately.
swissspidy commentedon Oct 19, 2018
@iamgabrielma That would be great, just so we can keep track of things. I'm not sure whether or how it can be fixed though. The reason why it works is simple I think: the shortcode block passes the string to
do_shortcode(), which obviously doesn't do anything. But later on, the embed handler parses the URL and turns it into an embed.youknowriad commentedon Jan 26, 2019
Is this still an issue, since WordPress don't support Medium by default, should we just close?
swissspidy commentedon Jan 26, 2019
I think so