OK that’s fine for old embeds, but my general point was that splitting strings is not bullet-proof and risks breaking in the future.
All of these are valid Vimeo URLs:
http://vimeo.com/14736353
https://www.vimeo.com/14736353
The embedded iframe itself ends up the same, so no issues here. We are just talking about a string to trigger the oEmbed feature.
As you said, the problem for now can be bypassed with the workaround of editing each and every post written in the past when Vimeo used the www prefix, so it’s not critical.
Maybe the title of this topic can be reworded as “do not rely on full URL string split to identify the provider and isolate the video ID for videos”, that’s probably a better way to word it and it’s not necessarily related to Vimeo. ??
Extending the idea a bit more…
Ideally, there could be a unique piece of code that extracts the domain for each embed, so that we can extend it in the future to support more providers. Contributors could just write a function that turns the embed URL into the thumbnail URL and each function would be associated with a whitelist of domains.
That would be really neat and could speed up contributions for additional embed.
Something like this (pseudo-code, not actual PHP):
function fetch_vimeo_thumb($url) {
get json from "https://vimeo.com/api/oembed.json?url=" . $url;
return json["thumbnail_url"];
}
$thumbnail_functions = [
"vimeo.com" => fetch_vimeo_thumb,
"youtube.com" => fetch_yt_thumb,
"youtu.be" => fetch_yt_thumb,
// [...]
];
The plugin could just use the array of functions and take care of the rest, like figuring out the domain of an embed, getting the thumbnail URL with the proper function, fetching the picture and storing the thumbnail in the correct place.
OK, this one is a feature idea and not a bug, I just thought it would be nice to write it down.
I’d like to add support for thumbnails of Slideshare embeds, let’s see if I can figure it out.