[wp-trac] [WordPress Trac] #44704: `wp.media.view.EmbedLink` and `oembed/1.0/proxy` don't work as expected

WordPress Trac noreply at wordpress.org
Thu Aug 2 14:43:51 UTC 2018


#44704: `wp.media.view.EmbedLink` and `oembed/1.0/proxy` don't work as expected
--------------------------+-----------------------------
 Reporter:  7studio       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Embeds        |    Version:  4.9.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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:

 1. Create a new post.
 2. Click on "Add Media" button.
 3. Choose "Insert from URL" interface.
 4. Paste a valid YouTube URL: https://www.youtube.com/watch?v=KA_CLal14u4
 5. See the YouTube `<iframe>` with a `600px` width.
 6. Click on "Insert into post" button.
 7. Publish post.
 8. Edit the YouTube video.
 9. See the YouTube `<iframe>` with a tiny `200px` 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:
 {{{#!js
 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:
 1. 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`.
 2. 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 ;)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44704>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list