I am looking to embed videos from websites that do not offer oembed support. I wrote some code but it's not working.
example link:
https://openload.co/f/onU1gT5mkJ8/A_date_with_Lazar_Angelov.mp4
example embed:
<iframe src="https://openload.co/embed/onU1gT5mkJ8/A_date_with_Lazar_Angelov.mp4" scrolling="no" frameborder="0" width="700" height="430" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
my code:
add_action( 'init', function()
{
wp_embed_register_handler(
'openload',
'#https://www\.openload\.co/f/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)?#i',
'wp_embed_handler_openload'
);
} );
function wp_embed_handler_openload( $matches, $attr, $url, $rawattr )
{
$embed = sprintf(
'<iframe class="openload-video" src="https://openload.co/embed/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)" scrolling="no" frameborder="0" width="700" height="430" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true">></iframe>',
esc_attr( $matches[1] )
);
return apply_filters( 'embed_openload', $embed, $matches, $attr, $url, $rawattr );
}
I really stucked at this. I would much appreciate any advice or links to any info that can help. Thanks!