Version Description
- Lazy load.
=
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 1.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.6.3
- admin/html/css/menu.css +1 -0
- admin/html/menu.html +51 -44
- admin/html/meta-box.html +4 -0
- admin/menu.php +3 -0
- featured-image-from-url.php +1 -1
- includes/html/js/jquery.lazyloadxt.extra.js +343 -0
- includes/html/script.html +1 -0
- includes/thumbnail.php +20 -4
- readme.txt +10 -2
admin/html/css/menu.css
CHANGED
@@ -50,6 +50,7 @@
|
|
50 |
th, td {
|
51 |
border-bottom: 1px solid #ddd;
|
52 |
padding-right: 32px;
|
|
|
53 |
}
|
54 |
|
55 |
th {
|
50 |
th, td {
|
51 |
border-bottom: 1px solid #ddd;
|
52 |
padding-right: 32px;
|
53 |
+
font-weight: normal;
|
54 |
}
|
55 |
|
56 |
th {
|
admin/html/menu.html
CHANGED
@@ -9,10 +9,7 @@
|
|
9 |
</div>
|
10 |
|
11 |
<div class="box">
|
12 |
-
|
13 |
-
<div class="greybox" style="background:#c5c6f9">
|
14 |
-
<div style="color:#0073aa">Reaching 100 positive reviews, </div> the "CSS Style" feature will be released for all users.
|
15 |
-
</div>
|
16 |
</div>
|
17 |
|
18 |
<div class="box">
|
@@ -231,6 +228,33 @@
|
|
231 |
</table>
|
232 |
</div>
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
<div class="box">
|
235 |
<h2>Social Tags</h2>
|
236 |
<div class="greybox" style="background:#e3ffe2">
|
@@ -287,6 +311,13 @@
|
|
287 |
</div>
|
288 |
</div>
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
<div class="box">
|
291 |
<h2>CSS Style</h2>
|
292 |
<div class="greybox" style="background:#ffe2e2">
|
@@ -912,13 +943,13 @@
|
|
912 |
<tr>
|
913 |
<th>Shop</th>
|
914 |
<th>
|
915 |
-
|
916 |
</th>
|
917 |
</tr>
|
918 |
<tr>
|
919 |
<th>Blog</th>
|
920 |
<th>
|
921 |
-
|
922 |
</th>
|
923 |
</tr>
|
924 |
</table>
|
@@ -935,13 +966,13 @@
|
|
935 |
<tr>
|
936 |
<th>Shop</th>
|
937 |
<th>
|
938 |
-
|
939 |
</th>
|
940 |
</tr>
|
941 |
<tr>
|
942 |
<th>Blog</th>
|
943 |
<th>
|
944 |
-
|
945 |
</th>
|
946 |
</tr>
|
947 |
</table>
|
@@ -966,9 +997,7 @@
|
|
966 |
Image
|
967 |
</th>
|
968 |
<th>
|
969 |
-
|
970 |
-
fifu_image_url
|
971 |
-
</p>
|
972 |
</th>
|
973 |
</tr>
|
974 |
<tr>
|
@@ -976,9 +1005,7 @@
|
|
976 |
Alt
|
977 |
</th>
|
978 |
<th>
|
979 |
-
|
980 |
-
fifu_image_alt
|
981 |
-
</p>
|
982 |
</th>
|
983 |
</tr>
|
984 |
<tr>
|
@@ -986,9 +1013,7 @@
|
|
986 |
Video
|
987 |
</th>
|
988 |
<th>
|
989 |
-
|
990 |
-
fifu_video_url
|
991 |
-
</p>
|
992 |
</th>
|
993 |
</tr>
|
994 |
<tr>
|
@@ -996,19 +1021,13 @@
|
|
996 |
Image Gallery
|
997 |
</th>
|
998 |
<th>
|
999 |
-
|
1000 |
-
fifu_image_url_0
|
1001 |
-
</p>
|
1002 |
</th>
|
1003 |
<th>
|
1004 |
-
|
1005 |
-
fifu_image_url_1
|
1006 |
-
</p>
|
1007 |
</th>
|
1008 |
<th>
|
1009 |
-
|
1010 |
-
...
|
1011 |
-
</p>
|
1012 |
</th>
|
1013 |
</tr>
|
1014 |
<tr>
|
@@ -1016,19 +1035,13 @@
|
|
1016 |
Video Gallery
|
1017 |
</th>
|
1018 |
<th>
|
1019 |
-
|
1020 |
-
fifu_video_url_0
|
1021 |
-
</p>
|
1022 |
</th>
|
1023 |
<th>
|
1024 |
-
|
1025 |
-
fifu_video_url_1
|
1026 |
-
</p>
|
1027 |
</th>
|
1028 |
<th>
|
1029 |
-
|
1030 |
-
...
|
1031 |
-
</p>
|
1032 |
</th>
|
1033 |
</tr>
|
1034 |
<tr>
|
@@ -1036,19 +1049,13 @@
|
|
1036 |
Slider
|
1037 |
</th>
|
1038 |
<th>
|
1039 |
-
|
1040 |
-
fifu_slider_image_url_0
|
1041 |
-
</p>
|
1042 |
</th>
|
1043 |
<th>
|
1044 |
-
|
1045 |
-
fifu_slider_image_url_1
|
1046 |
-
</p>
|
1047 |
</th>
|
1048 |
<th>
|
1049 |
-
|
1050 |
-
...
|
1051 |
-
</p>
|
1052 |
</th>
|
1053 |
</tr>
|
1054 |
</table>
|
9 |
</div>
|
10 |
|
11 |
<div class="box">
|
12 |
+
<h2>Value my work: give this plugin a <a href="https://wordpress.org/support/view/plugin-reviews/featured-image-from-url?filter=5" target="_blank">5-star</a> rating =)</h2>
|
|
|
|
|
|
|
13 |
</div>
|
14 |
|
15 |
<div class="box">
|
228 |
</table>
|
229 |
</div>
|
230 |
|
231 |
+
<div class="box">
|
232 |
+
<h2>Lazy Load</h2>
|
233 |
+
<div class="greybox" style="background:#e3ffe2">
|
234 |
+
Enabling this feature the images/videos won't be loaded until user scrolls to them. So it will make your home/shop load faster.
|
235 |
+
</div>
|
236 |
+
<br>
|
237 |
+
<form
|
238 |
+
id="fifu_form_lazy"
|
239 |
+
action="javascript:void(0)"
|
240 |
+
method="post">
|
241 |
+
<input
|
242 |
+
type="image"
|
243 |
+
href="javascript:void(0)"
|
244 |
+
id="fifu_toggle_lazy"
|
245 |
+
onclick="invert('lazy')"
|
246 |
+
name="fifu_toggle_lazy"
|
247 |
+
class="<?php echo $enable_lazy; ?>"
|
248 |
+
value=" "
|
249 |
+
style="display:block">
|
250 |
+
<input
|
251 |
+
type="hidden"
|
252 |
+
id="fifu_input_lazy"
|
253 |
+
name="fifu_input_lazy"
|
254 |
+
value="" >
|
255 |
+
</form>
|
256 |
+
</div>
|
257 |
+
|
258 |
<div class="box">
|
259 |
<h2>Social Tags</h2>
|
260 |
<div class="greybox" style="background:#e3ffe2">
|
311 |
</div>
|
312 |
</div>
|
313 |
|
314 |
+
<div class="box">
|
315 |
+
<h2>WP All Import</h2>
|
316 |
+
<div class="greybox" style="background:#e3ffe2">
|
317 |
+
You can use Featured Image from URL with WP All Import plugin. For that, use the custom field <b>fifu_image_url</b>. The other custom fields supported by FIFU are listed below, in the section WP REST API > Plugin Fields.
|
318 |
+
</div>
|
319 |
+
</div>
|
320 |
+
|
321 |
<div class="box">
|
322 |
<h2>CSS Style</h2>
|
323 |
<div class="greybox" style="background:#ffe2e2">
|
943 |
<tr>
|
944 |
<th>Shop</th>
|
945 |
<th>
|
946 |
+
http://yourdomain.com/wp-json/wc/v2/products
|
947 |
</th>
|
948 |
</tr>
|
949 |
<tr>
|
950 |
<th>Blog</th>
|
951 |
<th>
|
952 |
+
http://yourdomain.com/wp-json/wp/v2/posts
|
953 |
</th>
|
954 |
</tr>
|
955 |
</table>
|
966 |
<tr>
|
967 |
<th>Shop</th>
|
968 |
<th>
|
969 |
+
http://yourdomain.com/wp-json/wc/v2/products/{id}
|
970 |
</th>
|
971 |
</tr>
|
972 |
<tr>
|
973 |
<th>Blog</th>
|
974 |
<th>
|
975 |
+
http://yourdomain.com/wp-json/wp/v2/posts/{id}
|
976 |
</th>
|
977 |
</tr>
|
978 |
</table>
|
997 |
Image
|
998 |
</th>
|
999 |
<th>
|
1000 |
+
fifu_image_url
|
|
|
|
|
1001 |
</th>
|
1002 |
</tr>
|
1003 |
<tr>
|
1005 |
Alt
|
1006 |
</th>
|
1007 |
<th>
|
1008 |
+
fifu_image_alt
|
|
|
|
|
1009 |
</th>
|
1010 |
</tr>
|
1011 |
<tr>
|
1013 |
Video
|
1014 |
</th>
|
1015 |
<th>
|
1016 |
+
fifu_video_url
|
|
|
|
|
1017 |
</th>
|
1018 |
</tr>
|
1019 |
<tr>
|
1021 |
Image Gallery
|
1022 |
</th>
|
1023 |
<th>
|
1024 |
+
fifu_image_url_0
|
|
|
|
|
1025 |
</th>
|
1026 |
<th>
|
1027 |
+
fifu_image_url_1
|
|
|
|
|
1028 |
</th>
|
1029 |
<th>
|
1030 |
+
...
|
|
|
|
|
1031 |
</th>
|
1032 |
</tr>
|
1033 |
<tr>
|
1035 |
Video Gallery
|
1036 |
</th>
|
1037 |
<th>
|
1038 |
+
fifu_video_url_0
|
|
|
|
|
1039 |
</th>
|
1040 |
<th>
|
1041 |
+
fifu_video_url_1
|
|
|
|
|
1042 |
</th>
|
1043 |
<th>
|
1044 |
+
...
|
|
|
|
|
1045 |
</th>
|
1046 |
</tr>
|
1047 |
<tr>
|
1049 |
Slider
|
1050 |
</th>
|
1051 |
<th>
|
1052 |
+
fifu_slider_image_url_0
|
|
|
|
|
1053 |
</th>
|
1054 |
<th>
|
1055 |
+
fifu_slider_image_url_1
|
|
|
|
|
1056 |
</th>
|
1057 |
<th>
|
1058 |
+
...
|
|
|
|
|
1059 |
</th>
|
1060 |
</tr>
|
1061 |
</table>
|
admin/html/meta-box.html
CHANGED
@@ -49,10 +49,14 @@
|
|
49 |
<div style="<?php echo $show_news?>">
|
50 |
<br>
|
51 |
<hr>
|
|
|
|
|
52 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #ff5400; color: black;
|
53 |
background-color: #eee; border-radius: 15px 50px;">New premium feature: WP REST API integration</p>
|
54 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #c60013; color: black;
|
55 |
background-color: #eee; border-radius: 15px 50px;">Allows to set player parameters for YouTube videos now</p>
|
|
|
|
|
56 |
<center>
|
57 |
<table>
|
58 |
<tbody>
|
49 |
<div style="<?php echo $show_news?>">
|
50 |
<br>
|
51 |
<hr>
|
52 |
+
<p style="font-size: 12px; padding: 5px; border-left: 6px solid green; color: black;
|
53 |
+
background-color: #eee; border-radius: 15px 50px;">New free feature: Lazy Load</p>
|
54 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #ff5400; color: black;
|
55 |
background-color: #eee; border-radius: 15px 50px;">New premium feature: WP REST API integration</p>
|
56 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #c60013; color: black;
|
57 |
background-color: #eee; border-radius: 15px 50px;">Allows to set player parameters for YouTube videos now</p>
|
58 |
+
<p style="font-size: 12px; padding: 5px; border-left: 6px solid black; color: black;
|
59 |
+
background-color: #eee; border-radius: 15px 50px;"><a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">Vote</a> on the next free plugin feature</p>
|
60 |
<center>
|
61 |
<table>
|
62 |
<tbody>
|
admin/menu.php
CHANGED
@@ -15,6 +15,7 @@ function fifu_get_menu_html() {
|
|
15 |
|
16 |
$enable_woocommerce = get_option('fifu_woocommerce');
|
17 |
$enable_social = get_option('fifu_social');
|
|
|
18 |
$enable_content = get_option('fifu_content');
|
19 |
$enable_hide_page = get_option('fifu_hide_page');
|
20 |
$enable_hide_post = get_option('fifu_hide_post');
|
@@ -37,6 +38,7 @@ function fifu_get_menu_html() {
|
|
37 |
function fifu_get_menu_settings() {
|
38 |
fifu_get_setting('fifu_woocommerce');
|
39 |
fifu_get_setting('fifu_social');
|
|
|
40 |
fifu_get_setting('fifu_content');
|
41 |
fifu_get_setting('fifu_hide_page');
|
42 |
fifu_get_setting('fifu_hide_post');
|
@@ -65,6 +67,7 @@ function fifu_get_setting($type) {
|
|
65 |
function fifu_update_menu_options() {
|
66 |
fifu_update_option('fifu_input_woocommerce', 'fifu_woocommerce');
|
67 |
fifu_update_option('fifu_input_social', 'fifu_social');
|
|
|
68 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
69 |
fifu_update_option('fifu_input_hide_page', 'fifu_hide_page');
|
70 |
fifu_update_option('fifu_input_hide_post', 'fifu_hide_post');
|
15 |
|
16 |
$enable_woocommerce = get_option('fifu_woocommerce');
|
17 |
$enable_social = get_option('fifu_social');
|
18 |
+
$enable_lazy = get_option('fifu_lazy');
|
19 |
$enable_content = get_option('fifu_content');
|
20 |
$enable_hide_page = get_option('fifu_hide_page');
|
21 |
$enable_hide_post = get_option('fifu_hide_post');
|
38 |
function fifu_get_menu_settings() {
|
39 |
fifu_get_setting('fifu_woocommerce');
|
40 |
fifu_get_setting('fifu_social');
|
41 |
+
fifu_get_setting('fifu_lazy');
|
42 |
fifu_get_setting('fifu_content');
|
43 |
fifu_get_setting('fifu_hide_page');
|
44 |
fifu_get_setting('fifu_hide_post');
|
67 |
function fifu_update_menu_options() {
|
68 |
fifu_update_option('fifu_input_woocommerce', 'fifu_woocommerce');
|
69 |
fifu_update_option('fifu_input_social', 'fifu_social');
|
70 |
+
fifu_update_option('fifu_input_lazy', 'fifu_lazy');
|
71 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
72 |
fifu_update_option('fifu_input_hide_page', 'fifu_hide_page');
|
73 |
fifu_update_option('fifu_input_hide_post', 'fifu_hide_post');
|
featured-image-from-url.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* Plugin Name: Featured Image From URL
|
5 |
* Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
|
6 |
-
* Version: 1.6.
|
7 |
* Author: Marcel Jacques Machado
|
8 |
* Author URI: http://featuredimagefromurl.com/
|
9 |
*/
|
3 |
/*
|
4 |
* Plugin Name: Featured Image From URL
|
5 |
* Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
|
6 |
+
* Version: 1.6.3
|
7 |
* Author: Marcel Jacques Machado
|
8 |
* Author URI: http://featuredimagefromurl.com/
|
9 |
*/
|
includes/html/js/jquery.lazyloadxt.extra.js
ADDED
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Lazy Load XT v1.1.0 2016-01-12
|
2 |
+
* http://ressio.github.io/lazy-load-xt
|
3 |
+
* (C) 2016 RESS.io
|
4 |
+
* Licensed under MIT */
|
5 |
+
|
6 |
+
(function ($, window, document, undefined) {
|
7 |
+
// options
|
8 |
+
var lazyLoadXT = 'lazyLoadXT',
|
9 |
+
dataLazied = 'lazied',
|
10 |
+
load_error = 'load error',
|
11 |
+
classLazyHidden = 'lazy-hidden',
|
12 |
+
docElement = document.documentElement || document.body,
|
13 |
+
// force load all images in Opera Mini and some mobile browsers without scroll event or getBoundingClientRect()
|
14 |
+
forceLoad = (window.onscroll === undefined || !!window.operamini || !docElement.getBoundingClientRect),
|
15 |
+
options = {
|
16 |
+
autoInit: true, // auto initialize in $.ready
|
17 |
+
selector: 'img[data-src]', // selector for lazyloading elements
|
18 |
+
blankImage: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'.concat(Math.random().toString(36).substr(2)),
|
19 |
+
throttle: 99, // interval (ms) for changes check
|
20 |
+
forceLoad: forceLoad, // force auto load all images
|
21 |
+
|
22 |
+
//loadEvent: 'pageshow', // check AJAX-loaded content in jQueryMobile
|
23 |
+
updateEvent: 'load orientationchange resize scroll touchmove focus', // page-modified events
|
24 |
+
forceEvent: 'lazyloadall', // force loading of all elements
|
25 |
+
|
26 |
+
//onstart: null,
|
27 |
+
oninit: {removeClass: 'lazy'}, // init handler
|
28 |
+
onshow: {addClass: classLazyHidden}, // start loading handler
|
29 |
+
onload: {removeClass: classLazyHidden, addClass: 'lazy-loaded'}, // load success handler
|
30 |
+
onerror: {removeClass: classLazyHidden}, // error handler
|
31 |
+
//oncomplete: null, // complete handler
|
32 |
+
|
33 |
+
//scrollContainer: undefined,
|
34 |
+
checkDuplicates: true
|
35 |
+
},
|
36 |
+
elementOptions = {
|
37 |
+
srcAttr: 'data-src',
|
38 |
+
edgeX: 0,
|
39 |
+
edgeY: 512,
|
40 |
+
visibleOnly: true
|
41 |
+
},
|
42 |
+
$window = $(window),
|
43 |
+
$isFunction = $.isFunction,
|
44 |
+
$extend = $.extend,
|
45 |
+
$data = $.data || function (el, name) {
|
46 |
+
return $(el).data(name);
|
47 |
+
},
|
48 |
+
elements = [],
|
49 |
+
topLazy = 0,
|
50 |
+
/*
|
51 |
+
waitingMode=0 : no setTimeout
|
52 |
+
waitingMode=1 : setTimeout, no deferred events
|
53 |
+
waitingMode=2 : setTimeout, deferred events
|
54 |
+
*/
|
55 |
+
waitingMode = 0;
|
56 |
+
|
57 |
+
$[lazyLoadXT] = $extend(options, elementOptions, $[lazyLoadXT]);
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Return options.prop if obj.prop is undefined, otherwise return obj.prop
|
61 |
+
* @param {*} obj
|
62 |
+
* @param {*} prop
|
63 |
+
* @returns *
|
64 |
+
*/
|
65 |
+
function getOrDef(obj, prop) {
|
66 |
+
return obj[prop] === undefined ? options[prop] : obj[prop];
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @returns {number}
|
71 |
+
*/
|
72 |
+
function scrollTop() {
|
73 |
+
var scroll = window.pageYOffset;
|
74 |
+
return (scroll === undefined) ? docElement.scrollTop : scroll;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Add new elements to lazy-load list:
|
79 |
+
* $(elements).lazyLoadXT() or $(window).lazyLoadXT()
|
80 |
+
*
|
81 |
+
* @param {object} [overrides] override global options
|
82 |
+
*/
|
83 |
+
$.fn[lazyLoadXT] = function (overrides) {
|
84 |
+
overrides = overrides || {};
|
85 |
+
|
86 |
+
var blankImage = getOrDef(overrides, 'blankImage'),
|
87 |
+
checkDuplicates = getOrDef(overrides, 'checkDuplicates'),
|
88 |
+
scrollContainer = getOrDef(overrides, 'scrollContainer'),
|
89 |
+
forceShow = getOrDef(overrides, 'show'),
|
90 |
+
elementOptionsOverrides = {},
|
91 |
+
prop;
|
92 |
+
|
93 |
+
// empty overrides.scrollContainer is supported by both jQuery and Zepto
|
94 |
+
$(scrollContainer).on('scroll', queueCheckLazyElements);
|
95 |
+
|
96 |
+
for (prop in elementOptions) {
|
97 |
+
elementOptionsOverrides[prop] = getOrDef(overrides, prop);
|
98 |
+
}
|
99 |
+
|
100 |
+
return this.each(function (index, el) {
|
101 |
+
if (el === window) {
|
102 |
+
$(options.selector).lazyLoadXT(overrides);
|
103 |
+
} else {
|
104 |
+
var duplicate = checkDuplicates && $data(el, dataLazied),
|
105 |
+
$el = $(el).data(dataLazied, forceShow ? -1 : 1);
|
106 |
+
|
107 |
+
// prevent duplicates
|
108 |
+
if (duplicate) {
|
109 |
+
queueCheckLazyElements();
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
if (blankImage && el.tagName === 'IMG' && !el.src) {
|
114 |
+
el.src = blankImage;
|
115 |
+
}
|
116 |
+
|
117 |
+
// clone elementOptionsOverrides object
|
118 |
+
$el[lazyLoadXT] = $extend({}, elementOptionsOverrides);
|
119 |
+
|
120 |
+
triggerEvent('init', $el);
|
121 |
+
|
122 |
+
elements.push($el);
|
123 |
+
queueCheckLazyElements();
|
124 |
+
}
|
125 |
+
});
|
126 |
+
};
|
127 |
+
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Process function/object event handler
|
131 |
+
* @param {string} event suffix
|
132 |
+
* @param {jQuery} $el
|
133 |
+
*/
|
134 |
+
function triggerEvent(event, $el) {
|
135 |
+
var handler = options['on' + event];
|
136 |
+
if (handler) {
|
137 |
+
if ($isFunction(handler)) {
|
138 |
+
handler.call($el[0]);
|
139 |
+
} else {
|
140 |
+
if (handler.addClass) {
|
141 |
+
$el.addClass(handler.addClass);
|
142 |
+
}
|
143 |
+
if (handler.removeClass) {
|
144 |
+
$el.removeClass(handler.removeClass);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
$el.trigger('lazy' + event, [$el]);
|
150 |
+
|
151 |
+
// queue next check as images may be resized after loading of actual file
|
152 |
+
queueCheckLazyElements();
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Trigger onload/onerror handler
|
158 |
+
* @param {Event} e
|
159 |
+
*/
|
160 |
+
function triggerLoadOrError(e) {
|
161 |
+
triggerEvent(e.type, $(this).off(load_error, triggerLoadOrError));
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Load visible elements
|
167 |
+
* @param {bool} [force] loading of all elements
|
168 |
+
*/
|
169 |
+
function checkLazyElements(force) {
|
170 |
+
if (!elements.length) {
|
171 |
+
return;
|
172 |
+
}
|
173 |
+
|
174 |
+
force = force || options.forceLoad;
|
175 |
+
|
176 |
+
topLazy = Infinity;
|
177 |
+
|
178 |
+
var viewportTop = scrollTop(),
|
179 |
+
viewportHeight = window.innerHeight || docElement.clientHeight,
|
180 |
+
viewportWidth = window.innerWidth || docElement.clientWidth,
|
181 |
+
i,
|
182 |
+
length;
|
183 |
+
|
184 |
+
for (i = 0, length = elements.length; i < length; i++) {
|
185 |
+
var $el = elements[i],
|
186 |
+
el = $el[0],
|
187 |
+
objData = $el[lazyLoadXT],
|
188 |
+
removeNode = false,
|
189 |
+
visible = force || $data(el, dataLazied) < 0,
|
190 |
+
topEdge;
|
191 |
+
|
192 |
+
// remove items that are not in DOM
|
193 |
+
if (!$.contains(docElement, el)) {
|
194 |
+
removeNode = true;
|
195 |
+
} else if (force || !objData.visibleOnly || el.offsetWidth || el.offsetHeight) {
|
196 |
+
|
197 |
+
if (!visible) {
|
198 |
+
var elPos = el.getBoundingClientRect(),
|
199 |
+
edgeX = objData.edgeX,
|
200 |
+
edgeY = objData.edgeY;
|
201 |
+
|
202 |
+
topEdge = (elPos.top + viewportTop - edgeY) - viewportHeight;
|
203 |
+
|
204 |
+
visible = (topEdge <= viewportTop && elPos.bottom > -edgeY &&
|
205 |
+
elPos.left <= viewportWidth + edgeX && elPos.right > -edgeX);
|
206 |
+
}
|
207 |
+
|
208 |
+
if (visible) {
|
209 |
+
$el.on(load_error, triggerLoadOrError);
|
210 |
+
|
211 |
+
triggerEvent('show', $el);
|
212 |
+
|
213 |
+
var srcAttr = objData.srcAttr,
|
214 |
+
src = $isFunction(srcAttr) ? srcAttr($el) : el.getAttribute(srcAttr);
|
215 |
+
|
216 |
+
if (src) {
|
217 |
+
el.src = src;
|
218 |
+
}
|
219 |
+
|
220 |
+
removeNode = true;
|
221 |
+
} else {
|
222 |
+
if (topEdge < topLazy) {
|
223 |
+
topLazy = topEdge;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
if (removeNode) {
|
229 |
+
$data(el, dataLazied, 0);
|
230 |
+
elements.splice(i--, 1);
|
231 |
+
length--;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
if (!length) {
|
236 |
+
triggerEvent('complete', $(docElement));
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Run check of lazy elements after timeout
|
243 |
+
*/
|
244 |
+
function timeoutLazyElements() {
|
245 |
+
if (waitingMode > 1) {
|
246 |
+
waitingMode = 1;
|
247 |
+
checkLazyElements();
|
248 |
+
setTimeout(timeoutLazyElements, options.throttle);
|
249 |
+
} else {
|
250 |
+
waitingMode = 0;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Queue check of lazy elements because of event e
|
257 |
+
* @param {Event} [e]
|
258 |
+
*/
|
259 |
+
function queueCheckLazyElements(e) {
|
260 |
+
if (!elements.length) {
|
261 |
+
return;
|
262 |
+
}
|
263 |
+
|
264 |
+
// fast check for scroll event without new visible elements
|
265 |
+
if (e && e.type === 'scroll' && e.currentTarget === window) {
|
266 |
+
if (topLazy >= scrollTop()) {
|
267 |
+
return;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
if (!waitingMode) {
|
272 |
+
setTimeout(timeoutLazyElements, 0);
|
273 |
+
}
|
274 |
+
waitingMode = 2;
|
275 |
+
}
|
276 |
+
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Initialize list of hidden elements
|
280 |
+
*/
|
281 |
+
function initLazyElements() {
|
282 |
+
$window.lazyLoadXT();
|
283 |
+
}
|
284 |
+
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Loading of all elements
|
288 |
+
*/
|
289 |
+
function forceLoadAll() {
|
290 |
+
checkLazyElements(true);
|
291 |
+
}
|
292 |
+
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Initialization
|
296 |
+
*/
|
297 |
+
$(document).ready(function () {
|
298 |
+
triggerEvent('start', $window);
|
299 |
+
|
300 |
+
$window
|
301 |
+
.on(options.updateEvent, queueCheckLazyElements)
|
302 |
+
.on(options.forceEvent, forceLoadAll);
|
303 |
+
|
304 |
+
$(document).on(options.updateEvent, queueCheckLazyElements);
|
305 |
+
|
306 |
+
if (options.autoInit) {
|
307 |
+
$window.on(options.loadEvent, initLazyElements);
|
308 |
+
initLazyElements(); // standard initialization
|
309 |
+
}
|
310 |
+
});
|
311 |
+
|
312 |
+
})(window.jQuery || window.Zepto || window.$, window, document);
|
313 |
+
|
314 |
+
|
315 |
+
(function ($) {
|
316 |
+
var options = $.lazyLoadXT;
|
317 |
+
|
318 |
+
options.selector += ',video,iframe[data-src]';
|
319 |
+
options.videoPoster = 'data-poster';
|
320 |
+
|
321 |
+
$(document).on('lazyshow', 'video', function (e, $el) {
|
322 |
+
var srcAttr = $el.lazyLoadXT.srcAttr,
|
323 |
+
isFuncSrcAttr = $.isFunction(srcAttr),
|
324 |
+
changed = false;
|
325 |
+
|
326 |
+
$el.attr('poster', $el.attr(options.videoPoster));
|
327 |
+
$el.children('source,track')
|
328 |
+
.each(function (index, el) {
|
329 |
+
var $child = $(el),
|
330 |
+
src = isFuncSrcAttr ? srcAttr($child) : $child.attr(srcAttr);
|
331 |
+
if (src) {
|
332 |
+
$child.attr('src', src);
|
333 |
+
changed = true;
|
334 |
+
}
|
335 |
+
});
|
336 |
+
|
337 |
+
// reload video
|
338 |
+
if (changed) {
|
339 |
+
this.load();
|
340 |
+
}
|
341 |
+
});
|
342 |
+
|
343 |
+
})(window.jQuery || window.Zepto || window.$);
|
includes/html/script.html
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<script><?php include 'js/jquery.lazyloadxt.extra.js' ?></script>
|
includes/thumbnail.php
CHANGED
@@ -1,8 +1,13 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
add_filter('wp_head', 'fifu_add_social_tags');
|
4 |
add_filter('wp_head', 'fifu_add_sirv_js');
|
5 |
|
|
|
|
|
|
|
|
|
6 |
function fifu_add_social_tags() {
|
7 |
$post_id = get_the_ID();
|
8 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
@@ -45,10 +50,11 @@ function fifu_replace($html, $post_id) {
|
|
45 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
46 |
$alt = get_post_meta($post_id, 'fifu_image_alt', true);
|
47 |
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
|
|
52 |
}
|
53 |
|
54 |
function fifu_get_html($url, $alt) {
|
@@ -56,7 +62,7 @@ function fifu_get_html($url, $alt) {
|
|
56 |
if (is_plugin_active('sirv/sirv.php') && strpos($url, "sirv.com") !== false)
|
57 |
return sprintf('<!-- Featured Image From URL plugin --> <img class="Sirv" data-src="%s">', $url);
|
58 |
|
59 |
-
return sprintf('<!-- Featured Image From URL plugin --> <img
|
60 |
}
|
61 |
|
62 |
add_filter('the_content', 'fifu_add_to_content');
|
@@ -105,3 +111,13 @@ add_filter('genesis_get_image', 'fifu_genesis_image', 10, 4);
|
|
105 |
function fifu_genesis_image($args, $var1, $var2, $src) {
|
106 |
return $src ? fifu_replace($args, get_the_ID()) : $args;
|
107 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
add_filter('wp_head', 'fifu_add_js');
|
4 |
add_filter('wp_head', 'fifu_add_social_tags');
|
5 |
add_filter('wp_head', 'fifu_add_sirv_js');
|
6 |
|
7 |
+
function fifu_add_js() {
|
8 |
+
include 'html/script.html';
|
9 |
+
}
|
10 |
+
|
11 |
function fifu_add_social_tags() {
|
12 |
$post_id = get_the_ID();
|
13 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
50 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
51 |
$alt = get_post_meta($post_id, 'fifu_image_alt', true);
|
52 |
|
53 |
+
return empty($url) ? $html : fifu_get_html($url, $alt);
|
54 |
+
}
|
55 |
|
56 |
+
function is_ajax_call() {
|
57 |
+
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || wp_doing_ajax();
|
58 |
}
|
59 |
|
60 |
function fifu_get_html($url, $alt) {
|
62 |
if (is_plugin_active('sirv/sirv.php') && strpos($url, "sirv.com") !== false)
|
63 |
return sprintf('<!-- Featured Image From URL plugin --> <img class="Sirv" data-src="%s">', $url);
|
64 |
|
65 |
+
return sprintf('<!-- Featured Image From URL plugin --> <img %s alt="%s" style="%s">', fifu_lazy_url($url), $alt, fifu_should_hide() ? 'display:none' : '');
|
66 |
}
|
67 |
|
68 |
add_filter('the_content', 'fifu_add_to_content');
|
111 |
function fifu_genesis_image($args, $var1, $var2, $src) {
|
112 |
return $src ? fifu_replace($args, get_the_ID()) : $args;
|
113 |
}
|
114 |
+
|
115 |
+
function fifu_lazy_url($url) {
|
116 |
+
if (get_option('fifu_lazy') != 'toggleon' || is_ajax_call())
|
117 |
+
return 'src=' . $url;
|
118 |
+
return (is_home() || (class_exists('WooCommerce') && is_shop()) ? 'data-src=' : 'src=') . $url;
|
119 |
+
}
|
120 |
+
|
121 |
+
function fifu_lazy_load() {
|
122 |
+
return fifu_lazy_url('');
|
123 |
+
}
|
readme.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: marceljm
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
|
4 |
-
Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate, wp, rest, api, wp rest api
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.8
|
7 |
Stable tag: 4.8
|
@@ -24,6 +24,8 @@ Features:
|
|
24 |
|
25 |
* but if your theme show the Featured Images on posts/pages/products, there is an option to remove the Featured Image;
|
26 |
|
|
|
|
|
27 |
* all included content still has social tags to facilitate sharing on social networks;
|
28 |
|
29 |
* compatible with WP All Import plugin;
|
@@ -285,6 +287,9 @@ was removed. To finish, a Premium version is now been presented.
|
|
285 |
= 1.6.2 =
|
286 |
* Bug fix.
|
287 |
|
|
|
|
|
|
|
288 |
== Upgrade Notice ==
|
289 |
|
290 |
= 1.0 =
|
@@ -427,4 +432,7 @@ was removed. To finish, a Premium version is now been presented.
|
|
427 |
* Bug fix.
|
428 |
|
429 |
= 1.6.2 =
|
430 |
-
* Bug fix.
|
|
|
|
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: marceljm
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
|
4 |
+
Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate, wp, rest, api, wp rest api, lazy, load
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.8
|
7 |
Stable tag: 4.8
|
24 |
|
25 |
* but if your theme show the Featured Images on posts/pages/products, there is an option to remove the Featured Image;
|
26 |
|
27 |
+
* with lazy load feature the images/videos won't be loaded until user scrolls to them making the home/shop page load faster;
|
28 |
+
|
29 |
* all included content still has social tags to facilitate sharing on social networks;
|
30 |
|
31 |
* compatible with WP All Import plugin;
|
287 |
= 1.6.2 =
|
288 |
* Bug fix.
|
289 |
|
290 |
+
= 1.6.3 =
|
291 |
+
* Lazy load.
|
292 |
+
|
293 |
== Upgrade Notice ==
|
294 |
|
295 |
= 1.0 =
|
432 |
* Bug fix.
|
433 |
|
434 |
= 1.6.2 =
|
435 |
+
* Bug fix.
|
436 |
+
|
437 |
+
= 1.6.3 =
|
438 |
+
* Lazy load.
|