1//console.log(ElementorConfig['initial_document']['elements']); 2 3jQuery(function ($) { 4 5 $(document).ready(function () { 6 7 8 9 // Function to extract Vimeo ID from a Vimeo URL 10 11 function vtfe_get_vimeo_id(url) { 12 13 var vtfe_removeEnd = url.split('?')[0].split("/"); 14 15 var vtfe_vidId = vtfe_removeEnd[vtfe_removeEnd.length - 1]; 16 17 return vtfe_vidId; 18 19 } 20 21 22 23 // Function to extract YouTube ID from a YouTube URL 24 25 function vtfe_get_youtube_id(url) { 26 27 var vtfe_regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/; 28 29 var vtfe_match = url.match(vtfe_regExp); 30 31 return (vtfe_match && vtfe_match[7].length == 11) ? vtfe_match[7] : false; 32 33 } 34 35 36 37 // Find each Elementor embedded video with an image overlay set 38 39 40 41 if ( $('body').hasClass('elementor-editor-active') ) { 42 43 44 45 const vtfe_updateThumbnails = setInterval(function() { 46 47 48 49 $('.elementor-auto-video-thumbnailess').each(function() { 50 51 52 53 var vtfe_thisVideo = $(this); 54 55 56 57 // Remove image tags and only use the background image which we will blank at this stage 58 59 vtfe_thisVideo.find('img').remove(); 60 61 vtfe_thisVideo.attr('style', 'background-image: url("")'); 62 63 vtfe_thisVideo.addClass('elementor-auto-video-thumbnail-edit'); 64 65 66 67 }); 68 69 70 71 }, 1300); 72 73 74 75 } else { 76 77 78 79 const vtfe_updateThumbnails = setInterval(function() { 80 81 82 83 $('.elementor-auto-video-thumbnailess').each(function() { 84 85 86 87 var vtfe_thisVideo = $(this); 88 89 90 91 // Remove image tags and only use the background image which we will blank at this stage 92 93 vtfe_thisVideo.find('img').remove(); 94 95 vtfe_thisVideo.attr('style', 'background-image: url("")'); 96 97 98 99 var vtfe_videoURL = vtfe_thisVideo.closest('.elementor-widget-video').data('settings')['youtube_url']; 100 101 102 103 if (!vtfe_videoURL) { vtfe_videoURL = vtfe_thisVideo.closest('.elementor-widget-video').data('settings')['url']; } 104 105 if (!vtfe_videoURL && vtfe_thisVideo.parent().hasClass('elementor-open-lightbox')) { vtfe_videoURL = vtfe_thisVideo.data('elementor-lightbox')['youtube_url']; } 106 107 if (!vtfe_videoURL && vtfe_thisVideo.parent().hasClass('elementor-open-lightbox')) { vtfe_videoURL = vtfe_thisVideo.data('elementor-lightbox')['url']; } 108 109 if (!vtfe_videoURL) { vtfe_videoURL = vtfe_thisVideo.parent().find('iframe').data('lazy-load'); } 110 111 112 113 // Pull in the thumbnail for Vimeo videos 114 115 if (vtfe_videoURL.includes("vimeo")) { 116 117 var vtfe_vimeoId = vtfe_get_vimeo_id(vtfe_videoURL); 118 119 $.getJSON('https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/' + vtfe_vimeoId, { 120 121 format: "json", 122 123 width: "640" 124 125 }, 126 127 function (data) { 128 129 130 131 //thisImage.attr("src", data.thumbnail_url); 132 133 //thisImage.attr("srcset", data.thumbnail_url); 134 135 vtfe_thisVideo.attr('style', 'background-image: url("' + data.thumbnail_url +'")'); 136 137 138 139 // Set default alt and title of thumbnail 140 141 //thisImage.attr("alt", "Vimeo video thumbnail"); 142 143 //thisImage.attr("title", "Vimeo video"); 144 145 146 147 // Set title and alt from Vimeo data 148 149 if (data.title) { 150 151 var vtfe_vimeoTitle = data.title; 152 153 if (vtfe_vimeoTitle != "") { 154 155 //thisImage.attr("alt", "Vimeo video thumbnail for " + vtfe_vimeoTitle); 156 157 //thisImage.attr("title", "Video - " + vtfe_vimeoTitle); 158 159 } 160 161 } 162 163 164 165 } 166 167 ); 168 169 } 170 171 172 173 // Pull in the thumbnail for YouTube videos 174 175 if (vtfe_videoURL.includes("youtube") || vtfe_videoURL.includes("youtu.be")) { 176 177 vtfe_thisVideo.addClass('elementor-custom-embed-image-overlay-youtube'); 178 179 var vtfe_youtubeId = vtfe_get_youtube_id(vtfe_videoURL); 180 181 var vtfe_img = new Image(); 182 183 // Change thumbnail URL and alt 184 185 vtfe_img.onload = function () { 186 187 188 189 var vtfe_yt_thumbnail_url; 190 191 192 193 if (this.width < 1280) { 194 195 vtfe_yt_thumbnail_url = "https://i.ytimg.com/vi/" + vtfe_youtubeId + "/hqdefault.jpg"; 196 197 } else { 198 199 vtfe_yt_thumbnail_url = "https://i.ytimg.com/vi/" + vtfe_youtubeId + "/maxresdefault.jpg"; 200 201 } 202 203 204 205 //thisImage.attr("src", vtfe_yt_thumbnail_url); 206 207 //thisImage.attr("srcset", vtfe_yt_thumbnail_url); 208 209 vtfe_thisVideo.attr('style', 'background-image: url("' + vtfe_yt_thumbnail_url +'")'); 210 211 212 213 // Add default text for alt and title text of thumbnail 214 215 //thisImage.attr("alt", "YouTube video thumbnail"); 216 217 //thisImage.attr("title", "YouTube video"); 218 219 220 221 222 223 // Get YouTube video title for alt and title text of thumbnail - not currently in use 224 225 /* 226 227 function getYouTubeInfo() { 228 229 $.ajax({
230 231 url: "//gdata.youtube.com/feeds/api/videos/" + vtfe_youtubeId + "?v=2&alt=json", 232 233 dataType: "jsonp", 234 235 success: function (data) { getYTTitle(data); } 236 237 }); 238 239 } 240 241 function getYTTitle(data) { 242 243 var vtfe_title = data.entry.title.$t; 244 245 if (vtfe_title != "") { 246 247 thisImage.attr("alt", "YouTube video thumbnail for " + vtfe_title); 248 249 thisImage.attr("title", "Video - " + vtfe_title); 250 251 } 252 253 } 254 255 getYouTubeInfo(); 256 257 */ 258 259 } 260 261 if (!vtfe_img.src) { vtfe_img.src = "https://i.ytimg.com/vi/" + vtfe_youtubeId + "/maxresdefault.jpg"; } 262 263 if (!vtfe_img.srcset) { vtfe_img.srcset = "https://i.ytimg.com/vi/" + vtfe_youtubeId + "/maxresdefault.jpg"; } 264 265 266 267 } 268 269 270 271 $(this).removeClass('elementor-auto-video-thumbnailess'); 272 273 274 275 if ($('.elementor-auto-video-thumbnailess').length < 1) { 276 277 clearInterval(vtfe_updateThumbnails); 278 279 } 280 281 282 283 }); 284 285 286 287 }, 200); 288 289 } 290 291 }) 292 293})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.