Youtube iframe embed keeps disappearing from page

I am trying to embed a video on my homepage. I add the embed code from YouTube and paste it into a custom html blog on the gutenberg editor. I click update and check my website and the video is there. I refresh the page and the video disappears. I go to the page editor and the embedded code for the video has been removed. Please can someone tell me why this is happening? I have tried to research it …
Category: Web

how to show youtube comment profile pic in wordpress

i want to show youtube user's comment section profile pic in my wordpress comment section As i am fetching youtube video along with its commnets but i couldn't show user's profile image in my comment section in my blog comment i fetched with profile pic in blog comment section its showing blank or default image gravatar url i got for author https://yt3.ggpht.com/ytc/AKedOLRFowb1wyXwkxTIi3UgCrpJlBxZJuP4WLA9vK6f=s48-c-k-c0x00ffffff-no-rj|
Category: Web

How add class youtube and type/html to oembed code?

How can i add : class="youtube-player" type="text/html" to iframe like : function Oembed_youtube_no_title($html,$url,$args){ $url_string = parse_url($url, PHP_URL_QUERY); parse_str($url_string, $id); if (isset($id['v'])) { return '<iframe class="youtube-player" type="text/html" src="https://www.youtube.com/embed/' .$id['v'].'?vq=large&autohide=1&autoplay=1&fs=1&hl=fr&rel=0&loop=1" frameborder="0" allowfullscreen></iframe>'; } return $html; }
Category: Web

Is there a way to find all posts with Youtube video embedded?

Is there a way to search all posts and pages in my WordPress site and find those who have a Youtube video embedded in them? The reason to do that is I want to disable the wp-embed.min.js but before doing that, I need to confirm there are no posts or pages that embed Youtube videos. Update I create a test post and embed a Youtube video in it, and then check the HTML source, and find the following one: <div …
Category: Web

Thumbnail image doesn't show up in Shortcode output

A 'WordPress Shortcode' is being developed to display 'YouTube Channel Thumbnail' and 'Latest Playlist Thumbnail' when supplied with 'YouTube Channel ID' as follows. [yt_insert channel_id="UCbCmjCuTUZos6Inko4u57UQ"] Shortcode implementation is as follows. function yt_insert_decode( $atts ) { $atts = shortcode_atts( array( 'channel_id' => '' ), $atts ); $api_key = 'YOUTUBE_API_KEY'; $channel_id = $atts['channel_id']; $api_url = 'https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails&id=' . urlencode($channel_id) . '&key=' . $api_key; $api_response = wp_remote_get($api_url); $api_response = json_decode( wp_remote_retrieve_body($api_response) ); $channel_thumbnail = $api_response->items[0]->snippet->thumbnails->default->url; $playlist_id = $api_response->items[0]->contentDetails->relatedPlaylists->uploads; $playlist_endpoint = 'https://youtube.googleapis.com/youtube/v3/playlists?part=snippet&id=' . urlencode($playlist_id) . …
Category: Web

How to change thumbnail of embedded Youtube video?

When I embed a Youtube video onto my page, is there a way to change the thumbnail displayed (screenshot)? I do not have admin access to the Youtube video in-question. I would prefer a non-plugin solution if possible. I found these instructions, but they did not work.
Category: Web

Wordpress block editor embeds not working in theme (single.php)

I am trying to embed 'spotify' and 'youtube' services in the block editor. When added from the admin, they are displayed fine in the block editor, but when the post content is printed from the theme (single.php), only the respective urls are printed. The rendered HTML looks like: For Spotify: <figure class="wp-block-embed is-type-rich is-provider-spotify wp-block-embed-spotify wp-embed-aspect-21-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper"> https://open.spotify.com/episode/xxxxxx&dl_branch=1 </div></figure> For Youtube: <figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper"> https://www.youtube.com/watch?v=xxxxxx </div></figure> In single.php, I'm obtaining the post content through …
Category: Web

WordPress fails to embed video URL on specific theme

My developer created custom theme for WP, and for some reason Wordpress fails to embed video URL on user-end. Everything is fine with Default WP themes, also video is fine on visual mode, but if I try to switch to this theme- I see only the video URL, but not embed video. Looks like we need to add something to our theme, but can't find any manual - what we need to add to function.php? thanks
Category: Web

How to add srcdoc attribute to YouTube oEmbed in Gutenberg oEmbed Block

First of all, let me mention that I have already looked at the following two similar questions: Is it possible to modify the default YouTube embed attributes string? Filter oembeds tags to modify iframe attributes But both of them are pre Gutenberg era. So, while using Gutenberg oEmbed block to embed a YouTube video if I want to add a srcdoc attribute to it, is there a way to do it? Or do I have to create my custom block …
Category: Web

WordPress 5.3.x YouTube oEmbed is not working

We followed Brian Fegter's answer to display YouTube videos using WordPress' oEmbed feature: // Public video. $video_url = 'https://www.youtube.com/watch?v=1lODe0i7dNw'; require_once(ABSPATH . 'wp-includes/class-wp-oembed.php'); $oembed = new WP_oEmbed; // Auto-detect the video provider with the following $provider = $oembed->discover($video_url); $video = $oembed->fetch($provider, $video_url); echo $video->html; The code worked earlier. But right now it's not working. We're using WordPress 5.3.2. We tried updating WordPress to 5.3.6, but no luck. The main issue is: $oEmbed->discover() cannot detect any provider and returning false. :( You …
Category: Web

YouTube oEmbed and privacy-enhanced mode

When you´re embed a youtube video in an iframe, you can enable the privacy-enhanced mode, so YouTube doesn´t store information about your web page visitors until they play the video. I've tried to embed a video via oEmbed and the URL http://www.youtube-nocookie.com/embed/xA3tfBTvH0c but it didn't work. Is there a chance to implement a privacy-friendly solution with oEmbed? EDIT I found this proposal and tried to customize it and it seems to work, but there is one thing that is not …
Category: Web

Cannot embed YouTube video

I know of 3 ways to embed a YouTube video inside Gutenberg Just pasting the Embed code inside an HTML Block Just pasting the video URL Using the YouTube Block While method #1 seems to work without a problem, I cannot seem to be able to make the others work. I keep getting the message "Sorry, this content could not be embedded". I thought this might be a bug, so I updated to latest version, (5.5.1 at the time I …
Category: Web

Block editor: Sandbox iframe shows outdated HTML

Even if users disable the popular Lazy Load for Videos plugin and the frontend correctly resets videos so that videos are no longer lazy-loaded, the Gutenberg block does not get reset. Below screenshot shows how the iframe still includes the HTML of the deactivated plugin: I cleared my browser cache and cookies, I ensured the oembed metadata caches are emptied, and I tried to clear more caches using commands from How can I clear oEmbed caches for YouTube on posts …
Category: Web

YouTube API 403 error when website restriction set

I am loading the latest videos from a YouTube channel to WordPress, using the YouTube API: function load_feed() { $url = add_query_arg( array( 'part' => 'snippet', 'channelId' => '[YouTube channel ID]', 'maxResults' => 3, 'order' => 'date', 'type' => 'video', 'key' => '[YouTube API key]' ), 'https://www.googleapis.com/youtube/v3/search' ); $response = wp_remote_get(esc_url_raw($url)); return json_decode(wp_remote_retrieve_body($response), true); } Everything works well when in the API settings on Google Developers I have: Application restrictions: None But when I set: Application restrictions: HTTP referrers (web …
Category: Web

How can I grab the video id of youtube?

I tried $videoID = wp_oembed_get( get_post_meta( get_the_ID(), 'video_url', true ) ); but that doesn't seem to do anything. I'm trying to set playlist id as the video id so the video loops itself. function imp_custom_youtube_querystring( $html ) { if(strpos($html, 'youtube')!= FALSE) { $args = [ 'rel' => 0, 'showinfo' => 0, 'modestbranding' => 1, 'loop' => 1, ]; $videoID = wp_oembed_get( get_post_meta( get_the_ID(), 'video_url', true ) ); $params = '?version=3&playlist='.$videoID.'&'; foreach($args as $arg => $value){ $params .= $arg; $params .= …
Category: Web

Modify YouTube Embed Code to fit theme

I'm using a custom bootstrap template and other users will be embedding youtube videos, which I want to be responsive to fit the theme. What can I do to make the normal YouTube embed code, something like this: <iframe width="560" height="315" src="https://www.youtube.com/embed/2jna3dWEnzo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> Into this formatting (simplified and with class added): <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/2jna3dWEnzo" allowfullscreen></iframe> Any help would be fab!
Category: Web

YouTube Video autoplay

I am using a YouTube embed on my site. To make it autoplay I have added ?autoplay=1 to the embed too. The code when added to the page/post editor, is showing the video with autoplay. But on the front end, the video is not playing automatically. Is there any possible reason for that? Here is the code I am using: <iframe width="460" height="220" src="https://www.youtube.com/embed/rUWxSEwctFU?autoplay=1&controls=0&loop=1&playlist=rUWxSEwctFU&showinfo=0" frameborder="0" allowfullscreen allow="autoplay"></iframe> Can anyone please let me know what I am doing wrong here? Thank …
Category: Web

Embed youtube list with sidemenu opened

I'm an editor in a wordpress blog I have embedded an youtube list with this code: [youtube https://www.youtube.com/watch?v=*********&list=**************************] I want that the plalist has the sidemenu opened by defalut. How can I achieve that?
Category: Web

Filter for wp_embed_handler_youtube not working

In Wordpress 4.0, if I create a new post and paste a YouTube link directly into the post editor, Wordpress will automatically convert it to a YouTube embed tag. I'm trying to edit the default output for the embed tag with a filter function. I have a snippet set up like this: add_action( 'wp_embed_handler_youtube', 'bigger_youtube_embeds', 10, 4); function bigger_youtube_embeds($embed, $attr, $url, $rawattr) { // alter the $embed string... return $embed; } I tried this after viewing the following documentation: https://developer.wordpress.org/reference/hooks/wp_embed_handler_youtube/ …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.