Opened 6 years ago
Last modified 6 years ago
#44704 new defect (bug)
`wp.media.view.EmbedLink` and `oembed/1.0/proxy` don't work as expected
Reported by: | 7studio | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9.7 |
Component: | Embeds | Keywords: | |
Focuses: | Cc: |
Description
It seems that wp.media.view.EmbedLink
and the REST route oembed/1.0/proxy
don't respect the maxwidth
oEmbed parameter in all cases.
To Reproduce
Steps to reproduce the behaviour:
- Create a new post.
- Click on "Add Media" button.
- Choose "Insert from URL" interface.
- Paste a valid YouTube URL: https://www.youtube.com/watch?v=KA_CLal14u4
- See the YouTube
<iframe>
with a600px
width. - Click on "Insert into post" button.
- Publish post.
- Edit the YouTube video.
- See the YouTube
<iframe>
with a tiny200px
width.
Expected behaviour
The embed contents from Facebook or other services should have the same width when you add or edit them.
Reason found
After some researches, it seems that the problem comes from media-view.js
and this part of code:
this.dfd = wp.apiRequest({ url: wp.media.view.settings.oEmbedProxyUrl, data: { url: url, maxwidth: this.model.get( 'width' ), maxheight: this.model.get( 'height' ) }, type: 'GET', dataType: 'json', context: this })
I don't know why the embed content this.model.get( 'width' )
is egal to 0
when we edit it :/ As a result, the default value for the maxwidth
argument of the REST route oembed/1.0/proxy
can't be used like the first time.
Here is the requested URL:
- when we try to embed YouTube video:
http://v10.helloprojets.test/wp-json/oembed/1.0/proxy?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DscAxBpppwcQ%26list%3DPLoSIOFPSXQoOXzR8tpGC484wjgKFwIbWL%26index%3D78
. - when we edit the YouTube video:
http://v10.helloprojets.test/wp-json/oembed/1.0/proxy?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DscAxBpppwcQ%26list%3DPLoSIOFPSXQoOXzR8tpGC484wjgKFwIbWL%26index%3D78&maxwidth=&maxheight=
.
This problem is a bit weird and complex. I hope I was clear in my explanations ;)
Attachments (2)
Change History (4)
#2
@
6 years ago
@swissspidy I preferred to talk about oembed/1.0/proxy
too because the REST route could not accept zero/empty value for parameters and replace them by default values.
IMHO, it doesn't make sense to request content via oEmbed API with empty parameters (especially for YouTube and Dailymotion which return very small version of embeds without them). WordPress could handle/fix this developer mistake ;)
But you are right, the model data of wp.media.view.EmbedLink
isn't correctly set and it's the main problem.
Sounds to me like
oembed/1.0/proxy
works as expected though. It's just the model data that isn't set correctly.