Changeset 3027450
- Timestamp:
- 01/26/2024 05:18:15 PM (2 years ago)
- Location:
- simple-lazy-load-videos/trunk
- Files:
-
- 5 edited
-
assets/css/main.full.css (modified) (1 diff)
-
assets/js/scripts.js (modified) (1 diff)
-
includes/class-plugin.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
simple-lazy-load-videos.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-lazy-load-videos/trunk/assets/css/main.full.css
r2996110 r3027450 3 3 */ 4 4 /* ==|== primary styles ===================================================== 5 Authors: Valerii Bohdanov6 ========================================================================== */5 Authors: Valerii Bohdanov 6 ========================================================================== */ 7 7 /** 8 8 * Project only code -
simple-lazy-load-videos/trunk/assets/js/scripts.js
r2874846 r3027450 1 "use strict";!function(){function stop_all_video(){const videos=document.querySelectorAll(".sllv-video.-state_started");videos.length>0&&videos.forEach((video=>{video.querySelector(".sllv-video__iframe").remove(),video.classList.remove("-state_started")}))}!function(){const videos=document.querySelectorAll(".sllv-video");videos.length>0&&videos.forEach((video=>{!function(video){const link=video.querySelector(".sllv-video__link"),provider=video.getAttribute("data-provider"),id=video.getAttribute("data-video");video.addEventListener("click",(()=>{const iframe=function(provider,id){const iframe=document.createElement("iframe");return iframe.setAttribute("allowfullscreen",""),iframe.setAttribute("allow","autoplay"),iframe.setAttribute("src",function(provider,id){let url="";"youtube"==provider?url="https://www.youtube.com/embed/"+id+"?rel=0&showinfo=0&autoplay=1":"vimeo"==provider&&(url="https://player.vimeo.com/video/"+id+"?autoplay=1");return url}(provider,id)),iframe.classList.add("sllv-video__iframe"),iframe}(provider,id);stop_all_video(),function(){const html_media=document.querySelectorAll("video, audio");html_media.length>0&&html_media.forEach((media=>{media.pause()}))}(),video.appendChild(iframe),video.classList.add("-state_started")})),link.removeAttribute("href"),video.classList.add("-state_enabled")}(video)}))}(),document.querySelectorAll("video, audio").forEach((media=>{media.addEventListener("play",(()=>{stop_all_video()}))}))}();1 "use strict";!function(){function find_videos(){const videos=document.querySelectorAll(".sllv-video");videos.length>0&&videos.forEach((video=>{video.classList.contains("-state_enabled")||function(video){const link=video.querySelector(".sllv-video__link"),provider=video.getAttribute("data-provider"),id=video.getAttribute("data-video");video.addEventListener("click",(()=>{const iframe=function(provider,id){const iframe=document.createElement("iframe");return iframe.setAttribute("allowfullscreen",""),iframe.setAttribute("allow","autoplay"),iframe.setAttribute("src",function(provider,id){let url="";"youtube"==provider?url="https://www.youtube.com/embed/"+id+"?rel=0&showinfo=0&autoplay=1":"vimeo"==provider&&(url="https://player.vimeo.com/video/"+id+"?autoplay=1");return url}(provider,id)),iframe.classList.add("sllv-video__iframe"),iframe}(provider,id);stop_all_video(),function(){const html_media=document.querySelectorAll("video, audio");html_media.length>0&&html_media.forEach((media=>{media.pause()}))}(),video.appendChild(iframe),video.classList.add("-state_started")})),link.removeAttribute("href"),video.classList.add("-state_enabled")}(video)}))}function stop_all_video(){const videos=document.querySelectorAll(".sllv-video.-state_started");videos.length>0&&videos.forEach((video=>{video.querySelector(".sllv-video__iframe").remove(),video.classList.remove("-state_started")}))}find_videos(),document.querySelectorAll("video, audio").forEach((media=>{media.addEventListener("play",(()=>{stop_all_video()}))})),jQuery(document).ajaxComplete((function(event,request,settings){setTimeout((function(){find_videos()}),500)}))}(); -
simple-lazy-load-videos/trunk/includes/class-plugin.php
r2996110 r3027450 58 58 add_filter( 'embed_oembed_html', array( $this, 'change_oembed_html' ), 10, 4 ); 59 59 60 // Change video oEmbed HTML for BuddyPress. 61 add_filter( 'bp_embed_oembed_html', array( $this, 'bp_change_oembed_html' ), 10, 4 ); 62 60 63 // Add shortcodes. 61 64 add_shortcode( 'sllv_video', array( $this, 'shortcode' ) ); … … 159 162 ) ); 160 163 161 // replace default HTML by custom if exist.164 // Replace default HTML by custom if exist. 162 165 if ( $html ) { 163 166 $cache = $html; 164 167 } 168 } 169 170 return $cache; 171 } 172 173 174 /** 175 * Change video oEmbed HTML for BuddyPress. 176 * 177 * @since 1.4.0 178 * 179 * @param string $cache Cached HTML markup for embed. 180 * @param string $url The URL being embedded. 181 * @param array $attr Parsed shortcode attributes. 182 * @param array $rawattr Unparased shortcode attributes. 183 * @return string The returned oEmbed HTML. 184 */ 185 public function bp_change_oembed_html( $cache, $url, $attr, $rawattr ) { 186 $template = new \SLLV\Template(); 187 188 // Get oEmbed HTML from URL. 189 $html = $template->get_html_from_url( array( 190 'url' => $url, 191 ) ); 192 193 // Replace default HTML by custom if exist. 194 if ( $html ) { 195 $cache = $html; 165 196 } 166 197 -
simple-lazy-load-videos/trunk/readme.txt
r2996110 r3027450 4 4 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=V5Q9SBB54LMDC&source=url 5 5 Requires at least: 4.9 6 Tested up to: 6.4. 16 Tested up to: 6.4.2 7 7 Requires PHP: 5.6 8 Stable tag: 1. 3.08 Stable tag: 1.4.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 41 41 42 42 == Changelog == 43 = 1.4.0 = 44 * Add BuddyPress support 45 * Tested up to WordPress 6.4.2 46 43 47 = 1.3.0 = 44 48 * Remove styles from admin_enqueue_scripts -
simple-lazy-load-videos/trunk/simple-lazy-load-videos.php
r2996110 r3027450 4 4 * Plugin URI: https://github.com/radkill/simple-lazy-load-videos 5 5 * Description: Simple Lazy Load for embedded video from Youtube and Vimeo. 6 * Version: 1. 3.06 * Version: 1.4.0 7 7 * Requires at least: 4.9 8 8 * Requires PHP: 5.6
Note: See TracChangeset
for help on using the changeset viewer.