Version Description
- New option: Default Featured Image > Post Types; fix: CDN + Optimized Thumbnails (conflict with images from wp.com and other CDNs); fix: Lazy Load (images loaded twice).
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 3.7.0 |
Comparing to | |
See all releases |
Code changes from version 3.6.9 to 3.7.0
- admin/cli-commands.php +4 -0
- admin/db.php +5 -3
- admin/html/js/menu.js +1 -0
- admin/html/menu.html +68 -18
- admin/html/support-data.html +1 -0
- admin/menu.php +28 -10
- admin/strings.php +13 -1
- featured-image-from-url.php +2 -2
- includes/html/js/lazySizesConfig.js +6 -2
- includes/jetpack.php +32 -2
- includes/thumbnail.php +5 -3
- includes/util.php +15 -0
- readme.txt +6 -6
admin/cli-commands.php
CHANGED
@@ -163,6 +163,10 @@ class fifu_cli extends WP_CLI_Command {
|
|
163 |
fifu_db_delete_default_url();
|
164 |
return;
|
165 |
}
|
|
|
|
|
|
|
|
|
166 |
if (!empty($assoc_args['content-page'])) {
|
167 |
switch ($args[0]) {
|
168 |
case 'on':
|
163 |
fifu_db_delete_default_url();
|
164 |
return;
|
165 |
}
|
166 |
+
if (!empty($assoc_args['default-types'])) {
|
167 |
+
update_option('fifu_default_cpt', $args[0], 'no');
|
168 |
+
return;
|
169 |
+
}
|
170 |
if (!empty($assoc_args['content-page'])) {
|
171 |
switch ($args[0]) {
|
172 |
case 'on':
|
admin/db.php
CHANGED
@@ -353,11 +353,11 @@ class FifuDb {
|
|
353 |
return $result ? $result[0]->ids : null;
|
354 |
}
|
355 |
|
356 |
-
function get_posts_without_featured_image() {
|
357 |
return $this->wpdb->get_results("
|
358 |
SELECT id, post_title
|
359 |
FROM " . $this->posts . "
|
360 |
-
WHERE post_type IN ('$
|
361 |
AND post_status = 'publish'
|
362 |
AND NOT EXISTS (
|
363 |
SELECT 1
|
@@ -812,8 +812,10 @@ class FifuDb {
|
|
812 |
$att_id = get_option('fifu_default_attach_id');
|
813 |
if (!$att_id)
|
814 |
return;
|
|
|
|
|
815 |
$value = null;
|
816 |
-
foreach ($this->get_posts_without_featured_image() as $res) {
|
817 |
$aux = "(" . $res->id . ", '_thumbnail_id', " . $att_id . ")";
|
818 |
$value = $value ? $value . ',' . $aux : $aux;
|
819 |
}
|
353 |
return $result ? $result[0]->ids : null;
|
354 |
}
|
355 |
|
356 |
+
function get_posts_without_featured_image($post_types) {
|
357 |
return $this->wpdb->get_results("
|
358 |
SELECT id, post_title
|
359 |
FROM " . $this->posts . "
|
360 |
+
WHERE post_type IN ('$post_types')
|
361 |
AND post_status = 'publish'
|
362 |
AND NOT EXISTS (
|
363 |
SELECT 1
|
812 |
$att_id = get_option('fifu_default_attach_id');
|
813 |
if (!$att_id)
|
814 |
return;
|
815 |
+
$post_types = join("','", explode(',', str_replace(' ', '', get_option('fifu_default_cpt'))));
|
816 |
+
$post_types ? $post_types : $this->types;
|
817 |
$value = null;
|
818 |
+
foreach ($this->get_posts_without_featured_image($post_types) as $res) {
|
819 |
$aux = "(" . $res->id . ", '_thumbnail_id', " . $att_id . ")";
|
820 |
$value = $value ? $value . ',' . $aux : $aux;
|
821 |
}
|
admin/html/js/menu.js
CHANGED
@@ -48,6 +48,7 @@ jQuery(function () {
|
|
48 |
jQuery("#tabsPremium").tabs();
|
49 |
jQuery("#tabsWooImport").tabs();
|
50 |
jQuery("#tabsWpAllImport").tabs();
|
|
|
51 |
jQuery("#tabsShortcode").tabs();
|
52 |
jQuery("#tabsFifuShortcode").tabs();
|
53 |
jQuery("#tabsAutoSet").tabs();
|
48 |
jQuery("#tabsPremium").tabs();
|
49 |
jQuery("#tabsWooImport").tabs();
|
50 |
jQuery("#tabsWpAllImport").tabs();
|
51 |
+
jQuery("#tabsDefault").tabs();
|
52 |
jQuery("#tabsShortcode").tabs();
|
53 |
jQuery("#tabsFifuShortcode").tabs();
|
54 |
jQuery("#tabsAutoSet").tabs();
|
admin/html/menu.html
CHANGED
@@ -584,7 +584,7 @@
|
|
584 |
<?php $fifu['title']['default']() ?>
|
585 |
</th>
|
586 |
<th>
|
587 |
-
|
588 |
</th>
|
589 |
<th>
|
590 |
wp fifu image --default-url <string>
|
@@ -593,6 +593,23 @@
|
|
593 |
https://...
|
594 |
</th>
|
595 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
596 |
<tr class="color">
|
597 |
<th>
|
598 |
<?php $fifu['tab']['image']() ?>
|
@@ -2650,32 +2667,65 @@
|
|
2650 |
</div>
|
2651 |
|
2652 |
<div class="box">
|
2653 |
-
<
|
2654 |
-
id="fifu_form_default_url"
|
2655 |
-
action="javascript:void(0)"
|
2656 |
-
method="post">
|
2657 |
|
2658 |
-
|
|
|
|
|
2659 |
|
2660 |
-
|
2661 |
|
2662 |
-
|
2663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2664 |
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2670 |
|
2671 |
-
|
2672 |
-
|
2673 |
-
onclick="fifu_default_js()">
|
2674 |
|
|
|
|
|
|
|
2675 |
</div>
|
|
|
2676 |
|
2677 |
-
|
2678 |
|
|
|
|
|
|
|
|
|
2679 |
<input
|
2680 |
type="submit"
|
2681 |
href="javascript:void(0)"
|
584 |
<?php $fifu['title']['default']() ?>
|
585 |
</th>
|
586 |
<th>
|
587 |
+
<?php $fifu['default']['tab']['url']() ?>
|
588 |
</th>
|
589 |
<th>
|
590 |
wp fifu image --default-url <string>
|
593 |
https://...
|
594 |
</th>
|
595 |
</tr>
|
596 |
+
<tr class="color">
|
597 |
+
<th>
|
598 |
+
<?php $fifu['tab']['image']() ?>
|
599 |
+
</th>
|
600 |
+
<th>
|
601 |
+
<?php $fifu['title']['default']() ?>
|
602 |
+
</th>
|
603 |
+
<th>
|
604 |
+
<?php $fifu['default']['tab']['cpt']() ?>
|
605 |
+
</th>
|
606 |
+
<th>
|
607 |
+
wp fifu image --default-types <string>
|
608 |
+
</th>
|
609 |
+
<th>
|
610 |
+
post,page
|
611 |
+
</th>
|
612 |
+
</tr>
|
613 |
<tr class="color">
|
614 |
<th>
|
615 |
<?php $fifu['tab']['image']() ?>
|
2667 |
</div>
|
2668 |
|
2669 |
<div class="box">
|
2670 |
+
<h2><?php $fifu['title']['default']() ?></h2>
|
|
|
|
|
|
|
2671 |
|
2672 |
+
<div class="greybox">
|
2673 |
+
<?php $fifu['default']['desc']() ?>
|
2674 |
+
</div>
|
2675 |
|
2676 |
+
<br>
|
2677 |
|
2678 |
+
<div id="tabsDefault">
|
2679 |
+
<ul>
|
2680 |
+
<li><a href="#tabs-1"><?php $fifu['default']['tab']['url']() ?></a></li>
|
2681 |
+
<li><a href="#tabs-2"><?php $fifu['default']['tab']['cpt']() ?></a></li>
|
2682 |
+
</ul>
|
2683 |
+
<div id="tabs-1">
|
2684 |
+
<form
|
2685 |
+
id="fifu_form_default_url"
|
2686 |
+
action="javascript:void(0)"
|
2687 |
+
method="post">
|
2688 |
+
<input id="fifu_input_default_url"
|
2689 |
+
type="text"
|
2690 |
+
name="fifu_input_default_url"
|
2691 |
+
style="width:675px"
|
2692 |
+
value="<?php echo $default_url; ?>">
|
2693 |
|
2694 |
+
<input type="submit"
|
2695 |
+
value="<?php $fifu['button']['submit']() ?>"
|
2696 |
+
onclick="fifu_default_js()">
|
2697 |
+
</form>
|
2698 |
+
</div>
|
2699 |
+
<div id="tabs-2">
|
2700 |
+
<form
|
2701 |
+
id="fifu_form_default_cpt"
|
2702 |
+
action="javascript:void(0)"
|
2703 |
+
method="post">
|
2704 |
+
<input
|
2705 |
+
id="fifu_input_default_cpt"
|
2706 |
+
type="text"
|
2707 |
+
name="fifu_input_default_cpt"
|
2708 |
+
style="width:675px"
|
2709 |
+
value="<?php echo $default_cpt; ?>">
|
2710 |
+
<input
|
2711 |
+
type="submit"
|
2712 |
+
value="<?php $fifu['button']['submit']() ?>">
|
2713 |
|
2714 |
+
<span class="dashicons dashicons-editor-help" style="font-size: 25px; position: relative; top: 3px;" title="<?php printf($fifu['default']['cpt']['info'](), 'ol.flex-control-thumbs'); ?>"></span>
|
2715 |
+
</form>
|
|
|
2716 |
|
2717 |
+
<div style="position: relative; left:5px; top: 5px">
|
2718 |
+
<?php $fifu['default']['cpt']['found']() ?> <i><?php echo fifu_get_post_types_str() ?></i>
|
2719 |
+
</div>
|
2720 |
</div>
|
2721 |
+
</div>
|
2722 |
|
2723 |
+
<br>
|
2724 |
|
2725 |
+
<form
|
2726 |
+
id="fifu_form_enable_default_url"
|
2727 |
+
action="javascript:void(0)"
|
2728 |
+
method="post">
|
2729 |
<input
|
2730 |
type="submit"
|
2731 |
href="javascript:void(0)"
|
admin/html/support-data.html
CHANGED
@@ -34,6 +34,7 @@ fifu_content_cpt:<?php echo $enable_content_cpt ?>;
|
|
34 |
fifu_content_page:<?php echo $enable_content_page ?>;
|
35 |
fifu_data_clean:<?php echo $enable_data_clean ?>;
|
36 |
fifu_decode:<?php echo $enable_decode ?>;
|
|
|
37 |
fifu_default_url:<?php echo $default_url ?>;
|
38 |
fifu_dynamic_alt:<?php echo $enable_dynamic_alt ?>;
|
39 |
fifu_enable_default_url:<?php echo $enable_default_url ?>;
|
34 |
fifu_content_page:<?php echo $enable_content_page ?>;
|
35 |
fifu_data_clean:<?php echo $enable_data_clean ?>;
|
36 |
fifu_decode:<?php echo $enable_decode ?>;
|
37 |
+
fifu_default_cpt:<?php echo $default_cpt ?>;
|
38 |
fifu_default_url:<?php echo $default_url ?>;
|
39 |
fifu_dynamic_alt:<?php echo $enable_dynamic_alt ?>;
|
40 |
fifu_enable_default_url:<?php echo $enable_default_url ?>;
|
admin/menu.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_cdn_content', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_decode', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean')));
|
4 |
|
5 |
define('FIFU_SLUG', 'featured-image-from-url');
|
6 |
|
@@ -55,6 +55,7 @@ function fifu_support_data() {
|
|
55 |
$enable_content_cpt = get_option('fifu_content_cpt');
|
56 |
$enable_fake = get_option('fifu_fake');
|
57 |
$default_url = get_option('fifu_default_url');
|
|
|
58 |
$enable_default_url = get_option('fifu_enable_default_url');
|
59 |
$max_db = get_option('fifu_spinner_db');
|
60 |
$nth_image = get_option('fifu_spinner_nth');
|
@@ -112,6 +113,7 @@ function fifu_get_menu_html() {
|
|
112 |
$enable_content_cpt = get_option('fifu_content_cpt');
|
113 |
$enable_fake = get_option('fifu_fake');
|
114 |
$default_url = get_option('fifu_default_url');
|
|
|
115 |
$enable_default_url = get_option('fifu_enable_default_url');
|
116 |
$max_db = get_option('fifu_spinner_db');
|
117 |
$nth_image = get_option('fifu_spinner_nth');
|
@@ -140,14 +142,16 @@ function fifu_get_menu_html() {
|
|
140 |
$arr = fifu_update_menu_options();
|
141 |
|
142 |
// default
|
143 |
-
|
144 |
-
|
145 |
-
if (!
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
151 |
}
|
152 |
|
153 |
// reset
|
@@ -174,6 +178,7 @@ function fifu_get_setting($type) {
|
|
174 |
|
175 |
$arr1 = array('fifu_spinner_nth');
|
176 |
$arrEmpty = array('fifu_default_url');
|
|
|
177 |
$arr64 = array('fifu_column_height');
|
178 |
$arr1000 = array('fifu_spinner_db');
|
179 |
$arrOn = array('fifu_wc_zoom', 'fifu_wc_lbox');
|
@@ -185,6 +190,8 @@ function fifu_get_setting($type) {
|
|
185 |
update_option($type, '');
|
186 |
else if (in_array($type, $arr1))
|
187 |
update_option($type, 1);
|
|
|
|
|
188 |
else if (in_array($type, $arr64))
|
189 |
update_option($type, "64", 'no');
|
190 |
else if (in_array($type, $arr1000))
|
@@ -214,6 +221,7 @@ function fifu_update_menu_options() {
|
|
214 |
fifu_update_option('fifu_input_content_cpt', 'fifu_content_cpt');
|
215 |
fifu_update_option('fifu_input_fake', 'fifu_fake');
|
216 |
fifu_update_option('fifu_input_default_url', 'fifu_default_url');
|
|
|
217 |
fifu_update_option('fifu_input_enable_default_url', 'fifu_enable_default_url');
|
218 |
fifu_update_option('fifu_input_spinner_db', 'fifu_spinner_db');
|
219 |
fifu_update_option('fifu_input_spinner_nth', 'fifu_spinner_nth');
|
@@ -245,7 +253,17 @@ function fifu_update_menu_options() {
|
|
245 |
|
246 |
// urgent updates
|
247 |
$arr = array();
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
|
250 |
return $arr;
|
251 |
}
|
1 |
<?php
|
2 |
|
3 |
+
define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_cdn_content', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_default_cpt', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_decode', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean')));
|
4 |
|
5 |
define('FIFU_SLUG', 'featured-image-from-url');
|
6 |
|
55 |
$enable_content_cpt = get_option('fifu_content_cpt');
|
56 |
$enable_fake = get_option('fifu_fake');
|
57 |
$default_url = get_option('fifu_default_url');
|
58 |
+
$default_cpt = get_option('fifu_default_cpt');
|
59 |
$enable_default_url = get_option('fifu_enable_default_url');
|
60 |
$max_db = get_option('fifu_spinner_db');
|
61 |
$nth_image = get_option('fifu_spinner_nth');
|
113 |
$enable_content_cpt = get_option('fifu_content_cpt');
|
114 |
$enable_fake = get_option('fifu_fake');
|
115 |
$default_url = get_option('fifu_default_url');
|
116 |
+
$default_cpt = get_option('fifu_default_cpt');
|
117 |
$enable_default_url = get_option('fifu_enable_default_url');
|
118 |
$max_db = get_option('fifu_spinner_db');
|
119 |
$nth_image = get_option('fifu_spinner_nth');
|
142 |
$arr = fifu_update_menu_options();
|
143 |
|
144 |
// default
|
145 |
+
if (!$arr['fifu_default_cpt']) { # submit via post type form
|
146 |
+
$default_url = $arr['fifu_default_url']; # submit via default url form
|
147 |
+
if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake')) {
|
148 |
+
if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
|
149 |
+
$att_id = fifu_db_create_attachment($default_url);
|
150 |
+
update_option('fifu_default_attach_id', $att_id);
|
151 |
+
fifu_db_set_default_url();
|
152 |
+
} else
|
153 |
+
fifu_db_update_default_url($default_url);
|
154 |
+
}
|
155 |
}
|
156 |
|
157 |
// reset
|
178 |
|
179 |
$arr1 = array('fifu_spinner_nth');
|
180 |
$arrEmpty = array('fifu_default_url');
|
181 |
+
$arrDefaultType = array('fifu_default_cpt');
|
182 |
$arr64 = array('fifu_column_height');
|
183 |
$arr1000 = array('fifu_spinner_db');
|
184 |
$arrOn = array('fifu_wc_zoom', 'fifu_wc_lbox');
|
190 |
update_option($type, '');
|
191 |
else if (in_array($type, $arr1))
|
192 |
update_option($type, 1);
|
193 |
+
else if (in_array($type, $arrDefaultType))
|
194 |
+
update_option($type, "post,page,product", 'no');
|
195 |
else if (in_array($type, $arr64))
|
196 |
update_option($type, "64", 'no');
|
197 |
else if (in_array($type, $arr1000))
|
221 |
fifu_update_option('fifu_input_content_cpt', 'fifu_content_cpt');
|
222 |
fifu_update_option('fifu_input_fake', 'fifu_fake');
|
223 |
fifu_update_option('fifu_input_default_url', 'fifu_default_url');
|
224 |
+
fifu_update_option('fifu_input_default_cpt', 'fifu_default_cpt');
|
225 |
fifu_update_option('fifu_input_enable_default_url', 'fifu_enable_default_url');
|
226 |
fifu_update_option('fifu_input_spinner_db', 'fifu_spinner_db');
|
227 |
fifu_update_option('fifu_input_spinner_nth', 'fifu_spinner_nth');
|
253 |
|
254 |
// urgent updates
|
255 |
$arr = array();
|
256 |
+
if (isset($_POST['fifu_input_default_url'])) {
|
257 |
+
$arr['fifu_default_url'] = wp_strip_all_tags($_POST['fifu_input_default_url']);
|
258 |
+
} else {
|
259 |
+
$default_url = get_option('fifu_default_url');
|
260 |
+
$arr['fifu_default_url'] = $default_url ? $default_url : '';
|
261 |
+
}
|
262 |
+
|
263 |
+
if (isset($_POST['fifu_input_default_cpt'])) {
|
264 |
+
$arr['fifu_default_cpt'] = wp_strip_all_tags($_POST['fifu_input_default_cpt']);
|
265 |
+
} else
|
266 |
+
$arr['fifu_default_cpt'] = null;
|
267 |
|
268 |
return $arr;
|
269 |
}
|
admin/strings.php
CHANGED
@@ -725,7 +725,19 @@ function fifu_get_strings_settings() {
|
|
725 |
|
726 |
// default
|
727 |
$fifu['default']['desc'] = function() {
|
728 |
-
_e("Define the URL of a default image to be
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
729 |
};
|
730 |
|
731 |
// content
|
725 |
|
726 |
// default
|
727 |
$fifu['default']['desc'] = function() {
|
728 |
+
_e("Define the URL of a default image to be displayed when you create (or update) a post type with no featured image.", FIFU_SLUG);
|
729 |
+
};
|
730 |
+
$fifu['default']['tab']['url'] = function() {
|
731 |
+
_e("Image URL", FIFU_SLUG);
|
732 |
+
};
|
733 |
+
$fifu['default']['tab']['cpt'] = function() {
|
734 |
+
_e("Post types", FIFU_SLUG);
|
735 |
+
};
|
736 |
+
$fifu['default']['cpt']['found'] = function() {
|
737 |
+
_e("Post types found on your site: ", FIFU_SLUG);
|
738 |
+
};
|
739 |
+
$fifu['default']['cpt']['info'] = function() {
|
740 |
+
_e("After adding or removing a post type, you need to restart the feature by disabling and enabling the toggle below.", FIFU_SLUG);
|
741 |
};
|
742 |
|
743 |
// content
|
featured-image-from-url.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Plugin Name: Featured Image from URL (FIFU)
|
5 |
* Plugin URI: https://fifu.app/
|
6 |
* Description: Use an external image as featured image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
|
7 |
-
* Version: 3.
|
8 |
* Author: fifu.app
|
9 |
* Author URI: https://fifu.app/
|
10 |
* WC requires at least: 4.0
|
11 |
-
* WC tested up to: 5.
|
12 |
* Text Domain: featured-image-from-url
|
13 |
* License: GPLv3
|
14 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
4 |
* Plugin Name: Featured Image from URL (FIFU)
|
5 |
* Plugin URI: https://fifu.app/
|
6 |
* Description: Use an external image as featured image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
|
7 |
+
* Version: 3.7.0
|
8 |
* Author: fifu.app
|
9 |
* Author URI: https://fifu.app/
|
10 |
* WC requires at least: 4.0
|
11 |
+
* WC tested up to: 5.6
|
12 |
* Text Domain: featured-image-from-url
|
13 |
* License: GPLv3
|
14 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
includes/html/js/lazySizesConfig.js
CHANGED
@@ -21,6 +21,8 @@ function fifu_lazy() {
|
|
21 |
}
|
22 |
|
23 |
function fifu_add_lazyload($) {
|
|
|
|
|
24 |
jQuery($).addClass('lazyload');
|
25 |
}
|
26 |
|
@@ -45,8 +47,10 @@ function fifu_add_srcset() {
|
|
45 |
if (!srcset && !isMain) {
|
46 |
srcset = '';
|
47 |
sizes = [75, 100, 150, 240, 320, 500, 640, 800, 1024, 1280, 1600];
|
48 |
-
for (j = 0; j < sizes.length; j++)
|
49 |
-
|
|
|
|
|
50 |
jQuery(this).attr(types[i] + 'set', srcset);
|
51 |
jQuery(this).attr('data-sizes', 'auto');
|
52 |
}
|
21 |
}
|
22 |
|
23 |
function fifu_add_lazyload($) {
|
24 |
+
if (jQuery($).hasClass('lazyload') || jQuery($).hasClass('lazyloaded') || jQuery($).hasClass('lazyloading'))
|
25 |
+
return;
|
26 |
jQuery($).addClass('lazyload');
|
27 |
}
|
28 |
|
47 |
if (!srcset && !isMain) {
|
48 |
srcset = '';
|
49 |
sizes = [75, 100, 150, 240, 320, 500, 640, 800, 1024, 1280, 1600];
|
50 |
+
for (j = 0; j < sizes.length; j++) {
|
51 |
+
ssl = src.includes('ssl=1') ? '&ssl=1' : '';
|
52 |
+
srcset += ((j != 0) ? ', ' : '') + src.replace(src.split('?')[1], 'w=' + sizes[j] + '&resize=' + sizes[j] + ssl) + ' ' + sizes[j] + 'w';
|
53 |
+
}
|
54 |
jQuery(this).attr(types[i] + 'set', srcset);
|
55 |
jQuery(this).attr('data-sizes', 'auto');
|
56 |
}
|
includes/jetpack.php
CHANGED
@@ -17,7 +17,10 @@ function fifu_jetpack_get_set($url, $is_slider) {
|
|
17 |
}
|
18 |
|
19 |
function fifu_jetpack_blocked($url) {
|
20 |
-
|
|
|
|
|
|
|
21 |
foreach ($blocklist as $domain) {
|
22 |
if (strpos($url, $domain) !== false)
|
23 |
return true;
|
@@ -25,11 +28,23 @@ function fifu_jetpack_blocked($url) {
|
|
25 |
return false;
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
function fifu_jetpack_photon_url($url, $args) {
|
|
|
|
|
|
|
29 |
$image_url_parts = wp_parse_url($url);
|
30 |
if (!is_array($image_url_parts) || empty($image_url_parts['host']) || empty($image_url_parts['path']))
|
31 |
return $url;
|
32 |
-
$subdomain = abs(crc32($url) %
|
33 |
$host = $image_url_parts['host'];
|
34 |
$path = $image_url_parts['path'];
|
35 |
$photon_url = "https://i{$subdomain}.wp.com/{$host}{$path}";
|
@@ -38,3 +53,18 @@ function fifu_jetpack_photon_url($url, $args) {
|
|
38 |
return $photon_url;
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
function fifu_jetpack_blocked($url) {
|
20 |
+
if (fifu_is_photon_url($url))
|
21 |
+
return true;
|
22 |
+
|
23 |
+
$blocklist = array('amazon-adsystem.com', 'sapo.io', 'unsplash.com', 'i.guim.co.uk', 's.yimg.com', 's1.yimg.com', 'www.washingtonpost.com', 'pbs.twimg.com', 'www.aljazeera.com', 'image.influenster.com', 'api.screenshotmachine.com', 'rackcdn.com');
|
24 |
foreach ($blocklist as $domain) {
|
25 |
if (strpos($url, $domain) !== false)
|
26 |
return true;
|
28 |
return false;
|
29 |
}
|
30 |
|
31 |
+
function fifu_is_photon_url($url) {
|
32 |
+
$list = array('i0.wp.com', 'i1.wp.com', 'i2.wp.com', 'i3.wp.com');
|
33 |
+
foreach ($list as $domain) {
|
34 |
+
if (strpos($url, $domain) !== false)
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
|
40 |
function fifu_jetpack_photon_url($url, $args) {
|
41 |
+
if (fifu_is_photon_url($url))
|
42 |
+
return $url;
|
43 |
+
$url = fifu_remove_cdn_prefix($url);
|
44 |
$image_url_parts = wp_parse_url($url);
|
45 |
if (!is_array($image_url_parts) || empty($image_url_parts['host']) || empty($image_url_parts['path']))
|
46 |
return $url;
|
47 |
+
$subdomain = abs(crc32($url) % 4);
|
48 |
$host = $image_url_parts['host'];
|
49 |
$path = $image_url_parts['path'];
|
50 |
$photon_url = "https://i{$subdomain}.wp.com/{$host}{$path}";
|
53 |
return $photon_url;
|
54 |
}
|
55 |
|
56 |
+
function fifu_remove_cdn_prefix($url) {
|
57 |
+
if (strpos($url, '%3A%2F%2F') !== false)
|
58 |
+
$url = urldecode($url);
|
59 |
+
|
60 |
+
$aux = preg_split('/[\/=]https:\/\//', $url);
|
61 |
+
if (sizeof($aux) > 1)
|
62 |
+
return 'https://' . $aux[1];
|
63 |
+
|
64 |
+
$aux = preg_split('/[\/=]http:\/\//', $url);
|
65 |
+
if (sizeof($aux) > 1)
|
66 |
+
return 'http://' . $aux[1];
|
67 |
+
|
68 |
+
return $url;
|
69 |
+
}
|
70 |
+
|
includes/thumbnail.php
CHANGED
@@ -23,7 +23,7 @@ function fifu_add_js() {
|
|
23 |
echo '<link rel="preconnect" href="https://cdnjs.cloudflare.com">';
|
24 |
|
25 |
if (fifu_is_on('fifu_photon')) {
|
26 |
-
for ($i = 0; $i
|
27 |
echo "<link rel='preconnect' href='https://i{$i}.wp.com/' crossorigin>";
|
28 |
echo "<link rel='dns-prefetch' href='https://i{$i}.wp.com/'>";
|
29 |
}
|
@@ -211,8 +211,10 @@ function fifu_is_cpt() {
|
|
211 |
function fifu_main_image_url($post_id) {
|
212 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
213 |
|
214 |
-
if (!$url && fifu_no_internal_image($post_id) && (get_option('fifu_default_url') && fifu_is_on('fifu_enable_default_url')))
|
215 |
-
|
|
|
|
|
216 |
|
217 |
$url = htmlspecialchars_decode($url);
|
218 |
|
23 |
echo '<link rel="preconnect" href="https://cdnjs.cloudflare.com">';
|
24 |
|
25 |
if (fifu_is_on('fifu_photon')) {
|
26 |
+
for ($i = 0; $i <= 3; $i++) {
|
27 |
echo "<link rel='preconnect' href='https://i{$i}.wp.com/' crossorigin>";
|
28 |
echo "<link rel='dns-prefetch' href='https://i{$i}.wp.com/'>";
|
29 |
}
|
211 |
function fifu_main_image_url($post_id) {
|
212 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
213 |
|
214 |
+
if (!$url && fifu_no_internal_image($post_id) && (get_option('fifu_default_url') && fifu_is_on('fifu_enable_default_url'))) {
|
215 |
+
if (fifu_is_valid_default_cpt($post_id))
|
216 |
+
$url = get_option('fifu_default_url');
|
217 |
+
}
|
218 |
|
219 |
$url = htmlspecialchars_decode($url);
|
220 |
|
includes/util.php
CHANGED
@@ -96,6 +96,21 @@ function fifu_dashboard() {
|
|
96 |
(!class_exists('WooCommerce') || (class_exists('WooCommerce') && (!is_shop() && !is_product_category() && !is_cart())));
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
// developers
|
100 |
|
101 |
function fifu_dev_set_image($post_id, $image_url) {
|
96 |
(!class_exists('WooCommerce') || (class_exists('WooCommerce') && (!is_shop() && !is_product_category() && !is_cart())));
|
97 |
}
|
98 |
|
99 |
+
function fifu_get_default_cpt_arr() {
|
100 |
+
$cpts = get_option('fifu_default_cpt');
|
101 |
+
if (!$cpts)
|
102 |
+
return null;
|
103 |
+
return explode(',', str_replace(' ', '', $cpts));
|
104 |
+
}
|
105 |
+
|
106 |
+
function fifu_is_valid_default_cpt($post_id) {
|
107 |
+
$cpts = fifu_get_default_cpt_arr();
|
108 |
+
if (!$cpts)
|
109 |
+
return false;
|
110 |
+
$type = get_post_type($post_id);
|
111 |
+
return in_array($type, $cpts);
|
112 |
+
}
|
113 |
+
|
114 |
// developers
|
115 |
|
116 |
function fifu_dev_set_image($post_id, $image_url) {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
|
|
4 |
Tags: featured, image, url, video, woocommerce
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.8
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -224,20 +224,20 @@ Featured Image, Figurë e Zgjedhur, Image mise en avant, Uitgelichte afbeelding,
|
|
224 |
|
225 |
== Changelog ==
|
226 |
|
|
|
|
|
|
|
227 |
= 3.6.9 =
|
228 |
* Enhancement: CDN + Optimized Thumbnails (can work with post content images now); fix: CDN + Optimized Thumbnails (conflict with images from s.yimg.com).
|
229 |
|
230 |
= 3.6.8 =
|
231 |
* Enhancement: Auto set featured image using web page address (can work with videos now); fix: Default Featured Image (images not being displayed).
|
232 |
|
233 |
-
= 3.6.7 =
|
234 |
-
* New feature: Disable right-click; new options for CDN + Optimized Thumbnails: use CDN URLs in social tags and media RSS tags, crop images (to keep the aspect ratio defined by theme or WordPress media settings).
|
235 |
-
|
236 |
= others =
|
237 |
* [more](https://fifu.app/changelog)
|
238 |
|
239 |
|
240 |
== Upgrade Notice ==
|
241 |
|
242 |
-
= 3.
|
243 |
-
*
|
4 |
Tags: featured, image, url, video, woocommerce
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.8
|
7 |
+
Stable tag: 3.7.0
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
224 |
|
225 |
== Changelog ==
|
226 |
|
227 |
+
= 3.7.0 =
|
228 |
+
* New option: Default Featured Image > Post Types; fix: CDN + Optimized Thumbnails (conflict with images from wp.com and other CDNs); fix: Lazy Load (images loaded twice).
|
229 |
+
|
230 |
= 3.6.9 =
|
231 |
* Enhancement: CDN + Optimized Thumbnails (can work with post content images now); fix: CDN + Optimized Thumbnails (conflict with images from s.yimg.com).
|
232 |
|
233 |
= 3.6.8 =
|
234 |
* Enhancement: Auto set featured image using web page address (can work with videos now); fix: Default Featured Image (images not being displayed).
|
235 |
|
|
|
|
|
|
|
236 |
= others =
|
237 |
* [more](https://fifu.app/changelog)
|
238 |
|
239 |
|
240 |
== Upgrade Notice ==
|
241 |
|
242 |
+
= 3.7.0 =
|
243 |
+
* New option: Default Featured Image > Post Types; fix: CDN + Optimized Thumbnails (conflict with images from wp.com and other CDNs); fix: Lazy Load (images loaded twice).
|