Version Description
- Improvement: Save Image Dimensions is a little faster; bug fix: Image Metadata was slow after the last update; bug fix: conflicts with Jetpack plugin; bug fix: images not visible due unregistered theme sizes.
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 3.2.7 |
Comparing to | |
See all releases |
Code changes from version 3.2.6 to 3.2.7
- admin/api.php +5 -1
- admin/db.php +1 -1
- admin/html/js/menu.js +13 -21
- admin/html/menu.html +3 -3
- admin/menu.php +4 -6
- admin/meta-box.php +2 -2
- featured-image-from-url.php +2 -2
- includes/attachment.php +38 -3
- includes/util.php +4 -0
- readme.txt +6 -6
admin/api.php
CHANGED
@@ -2,18 +2,22 @@
|
|
2 |
|
3 |
function fifu_enable_fake_api(WP_REST_Request $request) {
|
4 |
update_option('fifu_fake_stop', false, 'no');
|
5 |
-
fifu_enable_fake(
|
|
|
6 |
return json_encode(array());
|
7 |
}
|
8 |
|
9 |
function fifu_disable_fake_api(WP_REST_Request $request) {
|
|
|
10 |
update_option('fifu_fake_stop', true, 'no');
|
|
|
11 |
return json_encode(array());
|
12 |
}
|
13 |
|
14 |
function fifu_data_clean_api(WP_REST_Request $request) {
|
15 |
fifu_db_enable_clean();
|
16 |
update_option('fifu_data_clean', 'toggleoff', 'no');
|
|
|
17 |
return json_encode(array());
|
18 |
}
|
19 |
|
2 |
|
3 |
function fifu_enable_fake_api(WP_REST_Request $request) {
|
4 |
update_option('fifu_fake_stop', false, 'no');
|
5 |
+
fifu_enable_fake();
|
6 |
+
update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
|
7 |
return json_encode(array());
|
8 |
}
|
9 |
|
10 |
function fifu_disable_fake_api(WP_REST_Request $request) {
|
11 |
+
update_option('fifu_fake_created', false, 'no');
|
12 |
update_option('fifu_fake_stop', true, 'no');
|
13 |
+
update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
|
14 |
return json_encode(array());
|
15 |
}
|
16 |
|
17 |
function fifu_data_clean_api(WP_REST_Request $request) {
|
18 |
fifu_db_enable_clean();
|
19 |
update_option('fifu_data_clean', 'toggleoff', 'no');
|
20 |
+
update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
|
21 |
return json_encode(array());
|
22 |
}
|
23 |
|
admin/db.php
CHANGED
@@ -602,9 +602,9 @@ class FifuDb {
|
|
602 |
$value = null;
|
603 |
$i = 1;
|
604 |
$count = 1;
|
|
|
605 |
// insert 1 attachment for each selected post
|
606 |
$result = $this->get_posts_without_meta();
|
607 |
-
$total = count($result);
|
608 |
foreach ($result as $res) {
|
609 |
$ids = ($i == 1) ? $res->post_id : ($ids . "," . $res->post_id);
|
610 |
$url = fifu_main_image_url($res->post_id);
|
602 |
$value = null;
|
603 |
$i = 1;
|
604 |
$count = 1;
|
605 |
+
$total = (int) $this->get_count_urls_without_metadata()[0]->amount;
|
606 |
// insert 1 attachment for each selected post
|
607 |
$result = $this->get_posts_without_meta();
|
|
|
608 |
foreach ($result as $res) {
|
609 |
$ids = ($i == 1) ? $res->post_id : ($ids . "," . $res->post_id);
|
610 |
$url = fifu_main_image_url($res->post_id);
|
admin/html/js/menu.js
CHANGED
@@ -97,7 +97,7 @@ function fifu_default_js() {
|
|
97 |
});
|
98 |
}
|
99 |
|
100 |
-
function fifu_fake_js(
|
101 |
jQuery('#tabs-top').block({message: fifuScriptVars.wait, css: {backgroundColor: 'none', border: 'none', color: 'white'}});
|
102 |
|
103 |
toggle = jQuery("#fifu_toggle_fake").attr('class');
|
@@ -120,9 +120,6 @@ function fifu_fake_js(savepoint) {
|
|
120 |
method: "POST",
|
121 |
url: restUrl + 'featured-image-from-url/v2/' + option + '/',
|
122 |
async: true,
|
123 |
-
data: {
|
124 |
-
"savepoint": savepoint,
|
125 |
-
},
|
126 |
beforeSend: function (xhr) {
|
127 |
xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
|
128 |
},
|
@@ -131,16 +128,13 @@ function fifu_fake_js(savepoint) {
|
|
131 |
jQuery('#tabs-top').unblock();
|
132 |
}, 1000);
|
133 |
jQuery("#countdown").load(location.href + " #countdown");
|
134 |
-
jQuery("#image_metadata_counter").
|
135 |
clearInterval(interval);
|
136 |
},
|
137 |
error: function (jqXHR, textStatus, errorThrown) {
|
138 |
console.log(jqXHR);
|
139 |
console.log(textStatus);
|
140 |
console.log(errorThrown);
|
141 |
-
setTimeout(function () {
|
142 |
-
fifu_fake_js(true);
|
143 |
-
}, 1000);
|
144 |
},
|
145 |
complete: function () {
|
146 |
},
|
@@ -220,10 +214,6 @@ function fifu_run_delete_all_js() {
|
|
220 |
function fifu_save_dimensions_all_js() {
|
221 |
jQuery('#tabs-top').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
|
222 |
|
223 |
-
interval = setInterval(function () {
|
224 |
-
jQuery("#countdown").load(location.href + " #countdown");
|
225 |
-
}, 3000);
|
226 |
-
|
227 |
jQuery.ajax({
|
228 |
method: "POST",
|
229 |
url: restUrl + 'featured-image-from-url/v2/list_all_without_dimensions/',
|
@@ -236,23 +226,25 @@ function fifu_save_dimensions_all_js() {
|
|
236 |
var count = data.length;
|
237 |
|
238 |
function dimensionsLoop(data, i) {
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
243 |
image = null;
|
244 |
i++;
|
245 |
-
if (
|
|
|
246 |
dimensionsLoop(data, i);
|
247 |
} else {
|
248 |
jQuery('#tabs-top').unblock();
|
249 |
invert('save_dimensions_all');
|
250 |
jQuery("#countdown").text('done');
|
251 |
}
|
252 |
-
}
|
253 |
-
}
|
254 |
-
fifu_save_dimensions_all_js();
|
255 |
-
}
|
256 |
}
|
257 |
|
258 |
if (data.length > 0) {
|
97 |
});
|
98 |
}
|
99 |
|
100 |
+
function fifu_fake_js() {
|
101 |
jQuery('#tabs-top').block({message: fifuScriptVars.wait, css: {backgroundColor: 'none', border: 'none', color: 'white'}});
|
102 |
|
103 |
toggle = jQuery("#fifu_toggle_fake").attr('class');
|
120 |
method: "POST",
|
121 |
url: restUrl + 'featured-image-from-url/v2/' + option + '/',
|
122 |
async: true,
|
|
|
|
|
|
|
123 |
beforeSend: function (xhr) {
|
124 |
xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
|
125 |
},
|
128 |
jQuery('#tabs-top').unblock();
|
129 |
}, 1000);
|
130 |
jQuery("#countdown").load(location.href + " #countdown");
|
131 |
+
jQuery("#image_metadata_counter").load(location.href + " #image_metadata_counter");
|
132 |
clearInterval(interval);
|
133 |
},
|
134 |
error: function (jqXHR, textStatus, errorThrown) {
|
135 |
console.log(jqXHR);
|
136 |
console.log(textStatus);
|
137 |
console.log(errorThrown);
|
|
|
|
|
|
|
138 |
},
|
139 |
complete: function () {
|
140 |
},
|
214 |
function fifu_save_dimensions_all_js() {
|
215 |
jQuery('#tabs-top').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
|
216 |
|
|
|
|
|
|
|
|
|
217 |
jQuery.ajax({
|
218 |
method: "POST",
|
219 |
url: restUrl + 'featured-image-from-url/v2/list_all_without_dimensions/',
|
226 |
var count = data.length;
|
227 |
|
228 |
function dimensionsLoop(data, i) {
|
229 |
+
var image = new Image();
|
230 |
+
jQuery(image).attr('src', data[i]['guid']);
|
231 |
+
|
232 |
+
var poll = setInterval(function () {
|
233 |
+
if (image.naturalWidth) {
|
234 |
+
clearInterval(poll);
|
235 |
+
fifu_get_sizes(image, data[i]['ID'], data[i]['guid']);
|
236 |
image = null;
|
237 |
i++;
|
238 |
+
if (i < data.length) {
|
239 |
+
jQuery("#countdown").text(parseInt(jQuery("#countdown").text()) - 1)
|
240 |
dimensionsLoop(data, i);
|
241 |
} else {
|
242 |
jQuery('#tabs-top').unblock();
|
243 |
invert('save_dimensions_all');
|
244 |
jQuery("#countdown").text('done');
|
245 |
}
|
246 |
+
}
|
247 |
+
}, 10);
|
|
|
|
|
248 |
}
|
249 |
|
250 |
if (data.length > 0) {
|
admin/html/menu.html
CHANGED
@@ -870,7 +870,7 @@
|
|
870 |
<?php esc_html_e('generate the missing metadata now:', 'featured-image-from-url'); ?>
|
871 |
</th>
|
872 |
<th>
|
873 |
-
<div id="image_metadata_counter"><?php echo
|
874 |
</th>
|
875 |
</tr>
|
876 |
</table>
|
@@ -925,7 +925,7 @@
|
|
925 |
<h2><?php esc_html_e('Save Image Dimensions', 'featured-image-from-url'); ?></h2>
|
926 |
|
927 |
<div class="greybox">
|
928 |
-
<?php esc_html_e('Some themes and plugins may not work correctly without image dimensions. This feature can get ~
|
929 |
</div>
|
930 |
|
931 |
<br>
|
@@ -2670,7 +2670,7 @@
|
|
2670 |
</tr>
|
2671 |
</table>
|
2672 |
<div class="greybox" style="position: relative; top: -10px">
|
2673 |
-
The import of
|
2674 |
1) deactivate FIFU;<br>
|
2675 |
2) import the products using the API;<br>
|
2676 |
3) activate FIFU;<br>
|
870 |
<?php esc_html_e('generate the missing metadata now:', 'featured-image-from-url'); ?>
|
871 |
</th>
|
872 |
<th>
|
873 |
+
<div id="image_metadata_counter"><?php echo get_option('fifu_image_metadata_counter') ?></div>
|
874 |
</th>
|
875 |
</tr>
|
876 |
</table>
|
925 |
<h2><?php esc_html_e('Save Image Dimensions', 'featured-image-from-url'); ?></h2>
|
926 |
|
927 |
<div class="greybox">
|
928 |
+
<?php esc_html_e('Some themes and plugins may not work correctly without image dimensions. This feature can get ~1 image dimension by second.', 'featured-image-from-url'); ?>
|
929 |
</div>
|
930 |
|
931 |
<br>
|
2670 |
</tr>
|
2671 |
</table>
|
2672 |
<div class="greybox" style="position: relative; top: -10px">
|
2673 |
+
The import of hundreds of thousands of products isn't fast enough:<br>
|
2674 |
1) deactivate FIFU;<br>
|
2675 |
2) import the products using the API;<br>
|
2676 |
3) activate FIFU;<br>
|
admin/menu.php
CHANGED
@@ -228,12 +228,10 @@ function fifu_update_option($input, $type) {
|
|
228 |
}
|
229 |
}
|
230 |
|
231 |
-
function fifu_enable_fake(
|
232 |
-
if (
|
233 |
-
|
234 |
-
|
235 |
-
update_option('fifu_fake_created', true, 'no');
|
236 |
-
}
|
237 |
|
238 |
fifu_db_change_url_length();
|
239 |
fifu_db_insert_attachment();
|
228 |
}
|
229 |
}
|
230 |
|
231 |
+
function fifu_enable_fake() {
|
232 |
+
if (get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
|
233 |
+
return;
|
234 |
+
update_option('fifu_fake_created', true, 'no');
|
|
|
|
|
235 |
|
236 |
fifu_db_change_url_length();
|
237 |
fifu_db_insert_attachment();
|
admin/meta-box.php
CHANGED
@@ -257,14 +257,14 @@ function fifu_variation_settings_fields($loop, $variation_data, $variation) {
|
|
257 |
/* dimensions */
|
258 |
|
259 |
function fifu_get_width_meta($req) {
|
260 |
-
if (isset($req['fifu_input_url']) && isset($req['fifu_input_image_width']))
|
261 |
return wp_strip_all_tags($req['fifu_input_image_width']);
|
262 |
|
263 |
return null;
|
264 |
}
|
265 |
|
266 |
function fifu_get_height_meta($req) {
|
267 |
-
if (isset($req['fifu_input_url']) && isset($req['fifu_input_image_height']))
|
268 |
return wp_strip_all_tags($req['fifu_input_image_height']);
|
269 |
|
270 |
return null;
|
257 |
/* dimensions */
|
258 |
|
259 |
function fifu_get_width_meta($req) {
|
260 |
+
if (isset($req['fifu_input_url']) && isset($req['fifu_input_image_width']) && $req['fifu_input_url'])
|
261 |
return wp_strip_all_tags($req['fifu_input_image_width']);
|
262 |
|
263 |
return null;
|
264 |
}
|
265 |
|
266 |
function fifu_get_height_meta($req) {
|
267 |
+
if (isset($req['fifu_input_url']) && isset($req['fifu_input_image_height']) && $req['fifu_input_url'])
|
268 |
return wp_strip_all_tags($req['fifu_input_image_height']);
|
269 |
|
270 |
return null;
|
featured-image-from-url.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Plugin Name: Featured Image from URL
|
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.2.
|
8 |
* Author: fifu.app
|
9 |
* Author URI: https://fifu.app/
|
10 |
* WC requires at least: 3.0
|
11 |
-
* WC tested up to: 4.
|
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
|
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.2.7
|
8 |
* Author: fifu.app
|
9 |
* Author URI: https://fifu.app/
|
10 |
* WC requires at least: 3.0
|
11 |
+
* WC tested up to: 4.4.0
|
12 |
* Text Domain: featured-image-from-url
|
13 |
* License: GPLv3
|
14 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
includes/attachment.php
CHANGED
@@ -103,6 +103,10 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
|
|
103 |
if (fifu_should_hide() && fifu_main_image_url($post->ID) == $image[0])
|
104 |
return null;
|
105 |
|
|
|
|
|
|
|
|
|
106 |
// use saved dimensions
|
107 |
if ($image[1] > 1 && $image[2] > 1)
|
108 |
return $image;
|
@@ -112,6 +116,20 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
|
|
112 |
|
113 |
function fifu_fix_dimensions($image, $size) {
|
114 |
// default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
if (!is_array($size)) {
|
116 |
if (function_exists('wp_get_registered_image_subsizes')) {
|
117 |
if (isset(wp_get_registered_image_subsizes()[$size]['width']))
|
@@ -127,10 +145,27 @@ function fifu_fix_dimensions($image, $size) {
|
|
127 |
$image[1] = $size[0];
|
128 |
$image[2] = $size[1];
|
129 |
}
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
return $image;
|
136 |
}
|
103 |
if (fifu_should_hide() && fifu_main_image_url($post->ID) == $image[0])
|
104 |
return null;
|
105 |
|
106 |
+
// photon
|
107 |
+
if (fifu_is_jetpack_active())
|
108 |
+
return fifu_get_photon_url($image, $size, $att_id);
|
109 |
+
|
110 |
// use saved dimensions
|
111 |
if ($image[1] > 1 && $image[2] > 1)
|
112 |
return $image;
|
116 |
|
117 |
function fifu_fix_dimensions($image, $size) {
|
118 |
// default
|
119 |
+
$image = fifu_add_size($image, $size);
|
120 |
+
|
121 |
+
// fix zoom
|
122 |
+
if (class_exists('WooCommerce') && is_product() && $image[1] == 1 && $image[2] == 1)
|
123 |
+
$image[1] = 1920;
|
124 |
+
|
125 |
+
// fix unkown size
|
126 |
+
if ($image[1] == 0 && $image[2] == 0)
|
127 |
+
$image[1] = 1920;
|
128 |
+
|
129 |
+
return $image;
|
130 |
+
}
|
131 |
+
|
132 |
+
function fifu_add_size($image, $size) {
|
133 |
if (!is_array($size)) {
|
134 |
if (function_exists('wp_get_registered_image_subsizes')) {
|
135 |
if (isset(wp_get_registered_image_subsizes()[$size]['width']))
|
145 |
$image[1] = $size[0];
|
146 |
$image[2] = $size[1];
|
147 |
}
|
148 |
+
return $image;
|
149 |
+
}
|
150 |
|
151 |
+
function fifu_get_photon_url($image, $size, $att_id) {
|
152 |
+
$image = fifu_add_size($image, $size);
|
153 |
+
$w = $image[1];
|
154 |
+
$h = $image[2];
|
155 |
+
|
156 |
+
$args = array();
|
157 |
+
|
158 |
+
if ($w > 0)
|
159 |
+
$args['w'] = $w;
|
160 |
+
|
161 |
+
if ($h > 0) {
|
162 |
+
$args['resize'] = array($w, $h);
|
163 |
+
$image[3] = true;
|
164 |
+
} else
|
165 |
+
$image[3] = $h > 0;
|
166 |
+
|
167 |
+
$image[0] = jetpack_photon_url($image[0], $args, null);
|
168 |
+
$image[0] = fifu_process_external_url($image[0], $att_id);
|
169 |
|
170 |
return $image;
|
171 |
}
|
includes/util.php
CHANGED
@@ -90,6 +90,10 @@ function fifu_is_elementor_editor() {
|
|
90 |
return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
93 |
// active themes
|
94 |
|
95 |
function fifu_is_avada_active() {
|
90 |
return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
|
91 |
}
|
92 |
|
93 |
+
function fifu_is_jetpack_active() {
|
94 |
+
return function_exists('jetpack_photon_url') && class_exists('Jetpack') && method_exists('Jetpack', 'get_active_modules') && in_array('photon', Jetpack::get_active_modules());
|
95 |
+
}
|
96 |
+
|
97 |
// active themes
|
98 |
|
99 |
function fifu_is_avada_active() {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
|
|
4 |
Tags: featured image, featured, image, url, thumbnail
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.5
|
7 |
-
Stable tag: 3.2.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -192,20 +192,20 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publiti
|
|
192 |
|
193 |
== Changelog ==
|
194 |
|
|
|
|
|
|
|
195 |
= 3.2.6 =
|
196 |
* Improvement: Image Metadata (added counter, savepoint and automatic restart after timeout); improvement: Status (query optimization); bug fix: some style issues (when there is no image dimensions); bug fix: notices and warnings; bug fix: Unsplash Image Search delay.
|
197 |
|
198 |
= 3.2.5 =
|
199 |
* Improvement: FIFU automatically saves the image dimensions now (for less style issues); deprecated: Original Sizes feature; bug fix: large URLs were being cropped; bug fix: menu settings was not being shown; bug fix: conflict with Accelerated Mobile Pages plugin; bug fix: conflict when category and product had the same ID; bug fix: conflict beteweem URL from Post Content and HTML character entities; bug fix: images not being shown in WooCommerce lightbox.
|
200 |
|
201 |
-
= 3.2.4 =
|
202 |
-
* Critical bug fix: conflict with URLs from Jetpack, Cloudinary and maybe others.
|
203 |
-
|
204 |
= others =
|
205 |
* [more](https://fifu.app/changelog/)
|
206 |
|
207 |
|
208 |
== Upgrade Notice ==
|
209 |
|
210 |
-
= 3.2.
|
211 |
-
* Improvement: Image
|
4 |
Tags: featured image, featured, image, url, thumbnail
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.5
|
7 |
+
Stable tag: 3.2.7
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
192 |
|
193 |
== Changelog ==
|
194 |
|
195 |
+
= 3.2.7 =
|
196 |
+
* Improvement: Save Image Dimensions is a little faster; bug fix: Image Metadata was slow after the last update; bug fix: conflicts with Jetpack plugin; bug fix: images not visible due unregistered theme sizes.
|
197 |
+
|
198 |
= 3.2.6 =
|
199 |
* Improvement: Image Metadata (added counter, savepoint and automatic restart after timeout); improvement: Status (query optimization); bug fix: some style issues (when there is no image dimensions); bug fix: notices and warnings; bug fix: Unsplash Image Search delay.
|
200 |
|
201 |
= 3.2.5 =
|
202 |
* Improvement: FIFU automatically saves the image dimensions now (for less style issues); deprecated: Original Sizes feature; bug fix: large URLs were being cropped; bug fix: menu settings was not being shown; bug fix: conflict with Accelerated Mobile Pages plugin; bug fix: conflict when category and product had the same ID; bug fix: conflict beteweem URL from Post Content and HTML character entities; bug fix: images not being shown in WooCommerce lightbox.
|
203 |
|
|
|
|
|
|
|
204 |
= others =
|
205 |
* [more](https://fifu.app/changelog/)
|
206 |
|
207 |
|
208 |
== Upgrade Notice ==
|
209 |
|
210 |
+
= 3.2.7 =
|
211 |
+
* Improvement: Save Image Dimensions is a little faster; bug fix: Image Metadata was slow after the last update; bug fix: conflicts with Jetpack plugin; bug fix: images not visible due unregistered theme sizes.
|