I'm using Wordpress 3.5 which natively supports embeds into posts and pages from many sites, YouTube included.
When I embed a Youtube video directly onto a post or a page (by simply copying and pasting the video url), it works fine and no cross-domain policy errors are thrown in Chrome or Firefox.
However, when I add the URL from a function inside a custom page template (outside the main loop), that I built for a custom post type, it throws an error.
Here is what my function looks like:
function my_tour_video()
{
global $post,
$wp_embed;
$my_tour_video = get_post_meta($post->ID, "_my_tour_video", true);
echo $wp_embed->run_shortcode('[embed]' . $my_tour_video . '[/embed]');
}
In my custom field I have tried the "embed" youtube url and also just the "watch" url copied and pasted from the browser.
You can try this sample url: http://www.youtube.com/embed/Y7AvqD2loX4
Error in Chrome looks something like:
Unsafe JavaScript attempt to access frame with URL http://www.mydomain.com from frame with URL http://www.youtube.com/embed/Y7AvqD2loX4. Domains, protocols and ports must match.
Any suggestions on how to do this the right way would be very helpful at this point.