最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Where does "rel=0" get removed from my YouTube parameters?

programmeradmin5浏览0评论

I prefer using &rel=0 as a YouTube parameter so that only MY videos get listed in the "More Videos" feature.

I have been using the following string in the WordPress editor for a couple of years and it has worked until a day or two ago.

;rel=0

Yes, many places inside WordPress "help" in converting that string to what some developer assumes I want, and removes the "rel=0" parameter. Today's result is an iframe like this:

<iframe title="Stress Pattern: 2-syllable verbs" width="700" height="394" src="" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>

What code stripped the "rel=0" ... and added all those strange "allow" parms?

I prefer using &rel=0 as a YouTube parameter so that only MY videos get listed in the "More Videos" feature.

I have been using the following string in the WordPress editor for a couple of years and it has worked until a day or two ago.

https://www.youtube/watch?v=PRw1q6aJtnQ&rel=0

Yes, many places inside WordPress "help" in converting that string to what some developer assumes I want, and removes the "rel=0" parameter. Today's result is an iframe like this:

<iframe title="Stress Pattern: 2-syllable verbs" width="700" height="394" src="https://www.youtube/embed/PRw1q6aJtnQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>

What code stripped the "rel=0" ... and added all those strange "allow" parms?

Share Improve this question asked Jan 22, 2020 at 12:24 Bob EastonBob Easton 1231 silver badge7 bronze badges 6
  • 1 This isn't something WP allows you to do unless you have the unfiltered_html capability, aka if you're an admin or a super admin on a multisite, and isn't how you're meant to do this. WP is supposed to strip things like iframes out of your content. – Tom J Nowell Commented Jan 22, 2020 at 12:33
  • 1 Also, the rel parameter changed in 2018, it doesn't mean the same thing developers.google/youtube/…, which editor are you using? What did you change a day or two ago that triggered this? ( this wouldn't have just started happening unless code changed, unless you're actually on WordPress or a managed host? That's important info to know ), and how are you embedding it into the post? There are several ways to embed things from youtube, but you didn't state which one you were using – Tom J Nowell Commented Jan 22, 2020 at 12:33
  • First: yes, rel=0 changed back in 2018, and I know exactly how it changed, I prefer the behavior it has had since that change. That's why I use it. – Bob Easton Commented Jan 22, 2020 at 14:59
  • Second: the iframe code was produced by WordPress, not me. It's a fallacy to think that WordPress strips out iframes when it actually produces them for valid reasons. Third: The editor is the Visual editor, non-Gutenberg. What I changed that triggered this is NOTHING. WP base code and plugins are changing constantly. WP is producing different code in that iframe now than it did a few days ago My question stands: Where does that code come from? – Bob Easton Commented Jan 22, 2020 at 15:11
  • Vitauts is correct: this is oEmbed. If you go to your video page on YouTube and search the page source for 'oEmbed' you'll find two links for json+oembed and xml+oembed: open one of those and you'll see the YouTube-provided iframe, e.g. here's the JSON version: youtube/… – Rup Commented Jan 22, 2020 at 17:11
 |  Show 1 more comment

1 Answer 1

Reset to default 2

Iframe content is generated by youtube itself, wordpress just requests it via oembed call. If you wish you can study wp-includes/class-oembed.php code, but that will not help you to change iframe parameters. For that you may apply embed_oembed_html filter, see https://developer.wordpress/reference/hooks/embed_oembed_html/. It receives iframe html code, so you can do some string replacements to change it.

发布评论

评论列表(0)

  1. 暂无评论