YouTube embed fails silently
|Reported by:||frankieandshadow||Owned by:|
I have never been able to get the YouTube embed to work by [embed] or just quoting the URL. I tried finding out why today, and tracing through what the code does, I find it times out trying to fetch JSON for the oEmbed data via php-cURL from YouTube. (In fact I think it is the DNS lookup that is particularly slow here, but I don't think it makes much difference where the cause is, and it seems to fail not just on the server I'm developing on, but also on other servers). It consistently takes about 7 seconds for YouTube to reply on the system I'm testing on, and I see the timeout is 5 seconds. Now I know what the problem is I have added a filter to increase the timeout.
The biggest problem though is that it fails quietly. There is no error message on saving a post. Secondly, it behaves randomly and marginally - sometimes it works, sometimes it doesn't, depending on the load at YouTube presumably.
I think the author should at least be told their post has failed and why. However, if the timeout is consistently too low, there is then no way to make it work, without changing PHP code in a much more knowledgeable way than a typical user.
Ideally, you'd then offer the opportunity to repost with a larger timeout. If this were available, then the post could be refused publication until it works.
Just increasing the default timeout globally isn't a good solution, as saves will appear to hang, and I don't really know what side effects that might have elsewhere.