{"id":30418,"date":"2015-12-01T18:32:01","date_gmt":"2015-12-01T13:02:01","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=30418"},"modified":"2015-12-07T13:22:35","modified_gmt":"2015-12-07T07:52:35","slug":"extract-thumbnail-from-youtube-video-url-and-embed-it-to-play-video-by-just-clicking-on-it","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/extract-thumbnail-from-youtube-video-url-and-embed-it-to-play-video-by-just-clicking-on-it\/","title":{"rendered":"Extract Thumbnail from youtube video url and embed it to play video by just clicking on it."},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>With the help of \u2018JQuery\u2019 codes we can <a title=\"How to Create Thumbnails for YouTube\" href=\"http:\/\/www.tothenew.com\/blog\/youtube-thumbnails-creation\/\">generate YouTube thumbnail<\/a> on our front end of the website. First of all you have to copy a simple youtube watch URL of any video from youtube site like \u2018https:\/\/www.youtube.com\/watch?v=ODG3Vg3C_20\u2019 ( it will be appear in the url bar when you open youtube site) and paste into a \u2018p\u2019 tag in the page of HTML, User can also change \u2018p\u2019 tag into another tag according to requirement in the script.<\/p>\n<p><strong>Where we can use<\/strong><\/p>\n<p>You can use this script in dynamically generated youtube codes from backend in wordpress, zoomla, and CMS based plateform, and it can be used if you want to click to play a video in popup with the help of plugin like FancyBox, ColorBox, etc.<\/p>\n<p><strong>Required supporting jquery.<\/strong><\/p>\n<p>&lt;script type=&#8217;text\/javascript&#8217; src=&#8217;http:\/\/code.jquery.com\/jquery-1.8.3.js&#8217;&gt;&lt;\/script&gt;<\/p>\n<p><strong>Required Css.<\/strong><\/p>\n<p>&lt;style&gt;<br \/>\na, p{ display:block; width:100%; float:left; font-size:0;}<br \/>\n&lt;\/style&gt;<\/p>\n<p><strong>Implemented Jquery code.<\/strong><\/p>\n<p>&lt;script&gt;<\/p>\n<p>$(document).ready(function(){<\/p>\n<p>function getYoutubeID(url) {<\/p>\n<p>var id = url.match(\/(?:https?:\\\/{2})?(?:w{3}\\.)?youtu(?:be)?\\.(?:com|be)(?:\\\/watch\\?v=|\\\/)([^\\s&amp;]+)\/);<\/p>\n<p>id = id[1];<\/p>\n<p>return id;<\/p>\n<p>};<\/p>\n<p>$(&#8216;p&#8217;).each(function() {<\/p>\n<p>var id = getYoutubeID($( this ).html());<\/p>\n<p>var thumb_url = &#8220;https:\/\/i.ytimg.com\/vi\/&#8221;+id+&#8221;\/mqdefault.jpg&#8221;;<\/p>\n<p>var youtube_url = &#8221; https:\/\/www.youtube.com\/embed\/&#8221;+id+&#8221;&#8221;;<\/p>\n<p>$(&#8216;&lt;a href=&#8221;&#8216;+youtube_url+'&#8221;&gt;&lt;img src=&#8221;&#8216;+thumb_url+'&#8221; \/&gt;&lt;\/a&gt;&#8217;).appendTo($( this ));<\/p>\n<p>});<\/p>\n<p>});<\/p>\n<p>&lt;\/script&gt;<\/p>\n<p><strong>HTML code (with youtube watch link).<\/strong><\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;p&gt;https:\/\/www.youtube.com\/watch?v=ODG3Vg3C_20&lt;\/p&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p><strong>Support browser<\/strong><\/p>\n<table width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100\"><strong>Browser<\/strong><\/td>\n<\/tr>\n<tr>\n<td>FireFox 3.6+<\/td>\n<\/tr>\n<tr>\n<td>Safari 5+<\/td>\n<\/tr>\n<tr>\n<td>Chrome 6<\/td>\n<\/tr>\n<tr>\n<td>Opera 10.5+<\/td>\n<\/tr>\n<tr>\n<td>IE 9 and above<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Introduction With the help of \u2018JQuery\u2019 codes we can generate YouTube thumbnail on our front end of the website. First of all you have to copy a simple youtube watch URL of any video from youtube site like \u2018https:\/\/www.youtube.com\/watch?v=ODG3Vg3C_20\u2019 ( it will be appear in the url bar when you open youtube site) and paste [&hellip;]<\/p>\n","protected":false},"author":346,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[1],"tags":[2870,2871],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/30418"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/346"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=30418"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/30418\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=30418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=30418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=30418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}