I am looking to embed videos from websites that do not offer oembed support, but the reference offered on wp codex about wp_embed_register_handler()
is just too broad for someone like me.
I tried uploading the example code into my themes functions.php
, which I thought would embed any forbes video from just the url, like oembed supported websites like youtube, but only outputs the link onto the post.
(note: all links are edited due to my low rep.)
In my case, I'm trying to add support for a website called myvi.ru
.
I would like to paste just the url into a post, and automatically make it output the embed iframe code.
For example, put
http:/www.myvi.ru/watch/Krishtianu-Ronaldu-na-ploschadi-Madrida_I8fWfbDia0ufHwP7W85ZBg2?ap=1
subbing //
to /
this into a post, instead having to get the actual embed code, which is this
iframe width="640" height="390" src="/myvi.ru/player/embed/html/o7wvdeXPclZHaazh9Rum_ZuqOtTxR2_ntg5OVhDEhxabugy0qLQDKTbQ0SRijDi8N0" frameborder="0" allowfullscreen></iframe
<>
taken out
I thought putting the following into the themes function.php would solve it, but no luck.
wp_embed_register_handler( 'myvi', '#http://(?:www)\.myvi\.ru/(?:video/embed/embed\.html|embedvideo/)\?show=([\d]+)&format=frame&height=([\d]+)&width=([\d]+)&video=(.+?)($|&)#i', 'wp_embed_handler_myvi' );
function wp_embed_handler_myvi( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="http:/www.myvi.ru/embed/embed.html?show=%1$s&format=frame&height=%2$s&width=%3$s&video=%4$s&mode=render" width="%3$spx" height="%2$spx" frameborder="0" allowfullscreen></iframe>',
esc_attr($matches[1]),
esc_attr($matches[2]),
esc_attr($matches[3]),
esc_attr($matches[4])
);
return apply_filters( 'embed_myvi', $embed, $matches, $attr, $url, $rawattr );
}
Could anyone please point me in the right direction? I've tried googling for other examples to learn from, but cannot find any, and am stuck. I would much appreciate any advice or links to any info that can help. Thanks!
@
in front of the username to ping it, like @musasi