Featured Image From URL - Version 3.2.6

Version Description

  • 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.
Download this release

Release Info

Developer marceljm
Plugin Icon 128x128 Featured Image From URL
Version 3.2.6
Comparing to
See all releases

Code changes from version 3.2.5 to 3.2.6

admin/api.php CHANGED
@@ -1,18 +1,13 @@
1
  <?php
2
 
3
  function fifu_enable_fake_api(WP_REST_Request $request) {
4
- fifu_enable_fake();
 
5
  return json_encode(array());
6
  }
7
 
8
  function fifu_disable_fake_api(WP_REST_Request $request) {
9
- fifu_disable_fake();
10
- delete_option('fifu_fake_attach_id');
11
- return json_encode(array());
12
- }
13
-
14
- function fifu_none_fake_api(WP_REST_Request $request) {
15
- update_option('fifu_fake_created', null, 'no');
16
  return json_encode(array());
17
  }
18
 
@@ -70,22 +65,6 @@ function fifu_save_sizes_api(WP_REST_Request $request) {
70
  if ($url != $guid)
71
  return $json;
72
 
73
- // mutex
74
- $count = 0;
75
- $timeout = 10;
76
- $got_lock = true;
77
- $fp = fopen(ABSPATH . 'fifu-lock', 'w') or die('Cannot create lock file');
78
- while (!flock($fp, LOCK_EX | LOCK_NB, $wouldblock)) {
79
- if ($wouldblock && $count++ < $timeout)
80
- sleep(1);
81
- else {
82
- $got_lock = false;
83
- break;
84
- }
85
- }
86
- if (!$got_lock)
87
- return $json;
88
-
89
  if (get_post_field('post_author', $att_id) != FIFU_AUTHOR)
90
  return;
91
 
@@ -124,11 +103,6 @@ add_action('rest_api_init', function () {
124
  'callback' => 'fifu_disable_fake_api',
125
  'permission_callback' => 'fifu_get_private_data_permissions_check',
126
  ));
127
- register_rest_route('featured-image-from-url/v2', '/none_fake_api/', array(
128
- 'methods' => 'POST',
129
- 'callback' => 'fifu_none_fake_api',
130
- 'permission_callback' => 'fifu_get_private_data_permissions_check',
131
- ));
132
  register_rest_route('featured-image-from-url/v2', '/data_clean_api/', array(
133
  'methods' => 'POST',
134
  'callback' => 'fifu_data_clean_api',
1
  <?php
2
 
3
  function fifu_enable_fake_api(WP_REST_Request $request) {
4
+ update_option('fifu_fake_stop', false, 'no');
5
+ fifu_enable_fake($request['savepoint']);
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
 
65
  if ($url != $guid)
66
  return $json;
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  if (get_post_field('post_author', $att_id) != FIFU_AUTHOR)
69
  return;
70
 
103
  'callback' => 'fifu_disable_fake_api',
104
  'permission_callback' => 'fifu_get_private_data_permissions_check',
105
  ));
 
 
 
 
 
106
  register_rest_route('featured-image-from-url/v2', '/data_clean_api/', array(
107
  'methods' => 'POST',
108
  'callback' => 'fifu_data_clean_api',
admin/db.php CHANGED
@@ -238,38 +238,63 @@ class FifuDb {
238
  FROM " . $this->posts . " p
239
  WHERE p.post_type = 'attachment'
240
  AND p.post_author = " . $this->author . "
241
- AND p.post_status NOT IN ('auto-draft', 'trash')
242
  AND NOT EXISTS (
243
  SELECT 1
244
  FROM " . $this->postmeta . " pm
245
  WHERE p.id = pm.post_id
246
- AND pm.meta_key IN ('_wp_attachment_metadata')
247
- )
248
- ORDER BY p.id DESC"
249
  );
250
  }
251
 
252
- // count posts urls with metadata
253
  function get_count_urls_with_metadata() {
254
  return $this->wpdb->get_results("
255
  SELECT COUNT(1) AS amount
256
- FROM " . $this->postmeta . " pm
257
- INNER JOIN " . $this->postmeta . " pm2 ON pm.post_id = pm2.post_id AND pm.meta_id <> pm2.meta_id AND pm2.meta_key = '_thumbnail_id'
258
- INNER JOIN " . $this->posts . " p ON p.id = pm2.meta_value AND p.post_author = " . $this->author . "
259
- WHERE pm.meta_key = 'fifu_image_url'
260
- AND (
261
- NOT EXISTS (SELECT 1 FROM " . $this->options . " WHERE option_name = 'fifu_fake_attach_id')
262
- OR pm2.meta_value <> (SELECT option_value FROM " . $this->options . " WHERE option_name = 'fifu_fake_attach_id')
263
- )"
264
  );
265
  }
266
 
267
- // count posts urls
268
  function get_count_urls() {
269
  return $this->wpdb->get_results("
270
- SELECT COUNT(DISTINCT pm.post_id) AS amount
271
- FROM " . $this->postmeta . " pm
272
- WHERE pm.meta_key = 'fifu_image_url'"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  );
274
  }
275
 
@@ -579,6 +604,7 @@ class FifuDb {
579
  $count = 1;
580
  // insert 1 attachment for each selected post
581
  $result = $this->get_posts_without_meta();
 
582
  foreach ($result as $res) {
583
  $ids = ($i == 1) ? $res->post_id : ($ids . "," . $res->post_id);
584
  $url = fifu_main_image_url($res->post_id);
@@ -590,6 +616,9 @@ class FifuDb {
590
  $this->insert_thumbnail_id($ids, false);
591
  $this->insert_attachment_meta_url($ids, false);
592
  $this->insert_attachment_meta_alt($ids, false);
 
 
 
593
  $ids = null;
594
  $value = null;
595
  $i = 1;
@@ -835,7 +864,6 @@ class FifuDb {
835
  delete_option('fifu_fake_attach_id');
836
  fifu_disable_fake();
837
  update_option('fifu_fake', 'toggleoff', 'no');
838
- update_option('fifu_fake_created', false, 'no');
839
  }
840
 
841
  /* delete all urls */
@@ -912,6 +940,12 @@ function fifu_db_count_urls_with_metadata() {
912
  return $aux ? $aux->amount : 0;
913
  }
914
 
 
 
 
 
 
 
915
  /* count: urls */
916
 
917
  function fifu_db_count_urls() {
238
  FROM " . $this->posts . " p
239
  WHERE p.post_type = 'attachment'
240
  AND p.post_author = " . $this->author . "
 
241
  AND NOT EXISTS (
242
  SELECT 1
243
  FROM " . $this->postmeta . " pm
244
  WHERE p.id = pm.post_id
245
+ AND pm.meta_key = '_wp_attachment_metadata'
246
+ )"
 
247
  );
248
  }
249
 
250
+ // count urls with metadata
251
  function get_count_urls_with_metadata() {
252
  return $this->wpdb->get_results("
253
  SELECT COUNT(1) AS amount
254
+ FROM " . $this->posts . " p
255
+ WHERE p.post_author = " . $this->author . ""
 
 
 
 
 
 
256
  );
257
  }
258
 
259
+ // count urls
260
  function get_count_urls() {
261
  return $this->wpdb->get_results("
262
+ SELECT SUM(id) AS amount
263
+ FROM (
264
+ SELECT count(post_id) AS id
265
+ FROM " . $this->postmeta . " pm
266
+ WHERE pm.meta_key LIKE 'fifu%'
267
+ AND pm.meta_key LIKE '%url%'
268
+ AND pm.meta_key NOT LIKE '%list%'
269
+ UNION
270
+ SELECT count(term_id) AS id
271
+ FROM " . $this->termmeta . " tm
272
+ WHERE tm.meta_key LIKE 'fifu%'
273
+ AND tm.meta_key LIKE '%url%'
274
+ ) x"
275
+ );
276
+ }
277
+
278
+ // count urls without metadata
279
+ function get_count_urls_without_metadata() {
280
+ return $this->wpdb->get_results("
281
+ SELECT SUM(amount) AS amount
282
+ FROM (
283
+ SELECT COUNT(1) AS amount
284
+ FROM " . $this->postmeta . " pm
285
+ WHERE pm.meta_key LIKE 'fifu%'
286
+ AND pm.meta_key LIKE '%url%'
287
+ AND pm.meta_key NOT LIKE '%list%'
288
+ UNION
289
+ SELECT COUNT(1) AS amount
290
+ FROM " . $this->termmeta . " tm
291
+ WHERE tm.meta_key LIKE 'fifu%'
292
+ AND tm.meta_key LIKE '%url%'
293
+ UNION
294
+ SELECT -COUNT(1) AS amount
295
+ FROM " . $this->posts . " p
296
+ WHERE p.post_author = " . $this->author . "
297
+ ) x"
298
  );
299
  }
300
 
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);
616
  $this->insert_thumbnail_id($ids, false);
617
  $this->insert_attachment_meta_url($ids, false);
618
  $this->insert_attachment_meta_alt($ids, false);
619
+ update_option('fifu_image_metadata_counter', $total - $count, 'no');
620
+ if (get_option('fifu_fake_stop'))
621
+ return;
622
  $ids = null;
623
  $value = null;
624
  $i = 1;
864
  delete_option('fifu_fake_attach_id');
865
  fifu_disable_fake();
866
  update_option('fifu_fake', 'toggleoff', 'no');
 
867
  }
868
 
869
  /* delete all urls */
940
  return $aux ? $aux->amount : 0;
941
  }
942
 
943
+ function fifu_db_count_urls_without_metadata() {
944
+ $db = new FifuDb();
945
+ $aux = $db->get_count_urls_without_metadata()[0];
946
+ return $aux ? $aux->amount : 0;
947
+ }
948
+
949
  /* count: urls */
950
 
951
  function fifu_db_count_urls() {
admin/html/js/menu.js CHANGED
@@ -3,8 +3,6 @@ jQuery(document).ready(function () {
3
  jQuery('div.wrap div.header-box div.notice').hide();
4
  jQuery('div.wrap div.header-box div#message').hide();
5
  jQuery('div.wrap div.header-box div.updated').remove();
6
- window.scrollTo(0, 0);
7
- jQuery('.wrap').css('opacity', 1);
8
  });
9
 
10
  var restUrl = fifu_get_rest_url();
@@ -46,6 +44,10 @@ jQuery(function () {
46
  jQuery("#tabsPremium").tabs();
47
  jQuery("#tabsWooImport").tabs();
48
  jQuery("#tabsWpAllImport").tabs();
 
 
 
 
49
  });
50
 
51
  function save(formName, url) {
@@ -95,7 +97,7 @@ function fifu_default_js() {
95
  });
96
  }
97
 
98
- function fifu_fake_js() {
99
  jQuery('#tabs-top').block({message: fifuScriptVars.wait, css: {backgroundColor: 'none', border: 'none', color: 'white'}});
100
 
101
  toggle = jQuery("#fifu_toggle_fake").attr('class');
@@ -107,27 +109,41 @@ function fifu_fake_js() {
107
  option = "disable_fake_api";
108
  break;
109
  default:
110
- option = "none_fake_api";
111
  }
 
 
 
 
 
112
  jQuery.ajax({
113
  method: "POST",
114
  url: restUrl + 'featured-image-from-url/v2/' + option + '/',
115
  async: true,
 
 
 
116
  beforeSend: function (xhr) {
117
  xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
118
  },
119
  success: function (data) {
 
 
 
 
 
 
120
  },
121
  error: function (jqXHR, textStatus, errorThrown) {
122
  console.log(jqXHR);
123
  console.log(textStatus);
124
  console.log(errorThrown);
125
- },
126
- complete: function () {
127
  setTimeout(function () {
128
- jQuery('#tabs-top').unblock();
129
  }, 1000);
130
  },
 
 
131
  timeout: 0
132
  });
133
  }
@@ -160,9 +176,12 @@ function fifu_run_clean_js() {
160
  setTimeout(function () {
161
  jQuery("#fifu_toggle_data_clean").attr('class', 'toggleoff');
162
  jQuery("#fifu_toggle_fake").attr('class', 'toggleoff');
 
 
163
  jQuery('#tabs-top').unblock();
164
  }, 1000);
165
- }
 
166
  });
167
  }
168
 
@@ -193,13 +212,18 @@ function fifu_run_delete_all_js() {
193
  jQuery("#fifu_toggle_run_delete_all").attr('class', 'toggleoff');
194
  jQuery('#tabs-top').unblock();
195
  }, 1000);
196
- }
 
197
  });
198
  }
199
 
200
  function fifu_save_dimensions_all_js() {
201
  jQuery('#tabs-top').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
202
 
 
 
 
 
203
  jQuery.ajax({
204
  method: "POST",
205
  url: restUrl + 'featured-image-from-url/v2/list_all_without_dimensions/',
@@ -208,29 +232,32 @@ function fifu_save_dimensions_all_js() {
208
  xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
209
  },
210
  success: function (data) {
211
- jQuery("#countdown").text(data.length);
212
  var i = 0;
213
  var count = data.length;
214
- function dimensionsLoop() {
215
- setTimeout(function () {
 
216
  var image = new Image();
217
- jQuery(image).attr('onload', 'fifu_get_sizes(this, ' + data[i]['ID'] + ')');
218
- jQuery(image).attr('src', data[i]['guid']);
219
- image = null;
220
- jQuery("#countdown").text(--count);
221
- i++;
222
- if (i < data.length)
223
- dimensionsLoop();
224
- else {
225
- jQuery('#tabs-top').unblock();
226
- invert('save_dimensions_all');
227
- jQuery("#countdown").text('done');
228
- }
229
- }, 500)
 
 
230
  }
231
- if (data.length > 0)
232
- dimensionsLoop();
233
- else {
 
234
  jQuery('#tabs-top').unblock();
235
  invert('save_dimensions_all');
236
  jQuery("#countdown").text('done');
@@ -240,9 +267,13 @@ function fifu_save_dimensions_all_js() {
240
  console.log(jqXHR);
241
  console.log(textStatus);
242
  console.log(errorThrown);
 
 
 
243
  },
244
  complete: function (data) {
245
- }
 
246
  });
247
  }
248
 
3
  jQuery('div.wrap div.header-box div.notice').hide();
4
  jQuery('div.wrap div.header-box div#message').hide();
5
  jQuery('div.wrap div.header-box div.updated').remove();
 
 
6
  });
7
 
8
  var restUrl = fifu_get_rest_url();
44
  jQuery("#tabsPremium").tabs();
45
  jQuery("#tabsWooImport").tabs();
46
  jQuery("#tabsWpAllImport").tabs();
47
+
48
+ // show settings
49
+ window.scrollTo(0, 0);
50
+ jQuery('.wrap').css('opacity', 1);
51
  });
52
 
53
  function save(formName, url) {
97
  });
98
  }
99
 
100
+ function fifu_fake_js(savepoint) {
101
  jQuery('#tabs-top').block({message: fifuScriptVars.wait, css: {backgroundColor: 'none', border: 'none', color: 'white'}});
102
 
103
  toggle = jQuery("#fifu_toggle_fake").attr('class');
109
  option = "disable_fake_api";
110
  break;
111
  default:
112
+ return;
113
  }
114
+
115
+ interval = setInterval(function () {
116
+ jQuery("#image_metadata_counter").load(location.href + " #image_metadata_counter");
117
+ }, 3000);
118
+
119
  jQuery.ajax({
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
  },
129
  success: function (data) {
130
+ setTimeout(function () {
131
+ jQuery('#tabs-top').unblock();
132
+ }, 1000);
133
+ jQuery("#countdown").load(location.href + " #countdown");
134
+ jQuery("#image_metadata_counter").text('done');
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
+ },
147
  timeout: 0
148
  });
149
  }
176
  setTimeout(function () {
177
  jQuery("#fifu_toggle_data_clean").attr('class', 'toggleoff');
178
  jQuery("#fifu_toggle_fake").attr('class', 'toggleoff');
179
+ jQuery("#image_metadata_counter").load(location.href + " #image_metadata_counter");
180
+ jQuery("#countdown").load(location.href + " #countdown");
181
  jQuery('#tabs-top').unblock();
182
  }, 1000);
183
+ },
184
+ timeout: 0
185
  });
186
  }
187
 
212
  jQuery("#fifu_toggle_run_delete_all").attr('class', 'toggleoff');
213
  jQuery('#tabs-top').unblock();
214
  }, 1000);
215
+ },
216
+ timeout: 0
217
  });
218
  }
219
 
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/',
232
  xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
233
  },
234
  success: function (data) {
 
235
  var i = 0;
236
  var count = data.length;
237
+
238
+ function dimensionsLoop(data, i) {
239
+ try {
240
  var image = new Image();
241
+ jQuery(image).attr('src', data[i]['guid']).load(function () {
242
+ fifu_get_sizes(this, data[i]['ID']);
243
+ image = null;
244
+ i++;
245
+ if (parseInt(jQuery("#countdown").text()) > 0) {
246
+ dimensionsLoop(data, i);
247
+ } else {
248
+ jQuery('#tabs-top').unblock();
249
+ invert('save_dimensions_all');
250
+ jQuery("#countdown").text('done');
251
+ }
252
+ });
253
+ } catch (e) {
254
+ fifu_save_dimensions_all_js();
255
+ }
256
  }
257
+
258
+ if (data.length > 0) {
259
+ dimensionsLoop(data, i);
260
+ } else {
261
  jQuery('#tabs-top').unblock();
262
  invert('save_dimensions_all');
263
  jQuery("#countdown").text('done');
267
  console.log(jqXHR);
268
  console.log(textStatus);
269
  console.log(errorThrown);
270
+ setTimeout(function () {
271
+ fifu_save_dimensions_all_js();
272
+ }, 1000);
273
  },
274
  complete: function (data) {
275
+ },
276
+ timeout: 0
277
  });
278
  }
279
 
admin/html/js/meta-box.js CHANGED
@@ -36,8 +36,11 @@ function previewImage() {
36
  runPreview($url);
37
  }
38
  setTimeout(function () {
39
- jQuery("#fifu_next").show();
40
  jQuery('#fifu_button').parent().parent().unblock();
 
 
 
41
  }, 2000);
42
  }
43
  }
36
  runPreview($url);
37
  }
38
  setTimeout(function () {
39
+ jQuery("#fifu_next").hide();
40
  jQuery('#fifu_button').parent().parent().unblock();
41
+ setTimeout(function () {
42
+ jQuery("#fifu_next").show();
43
+ }, 2000);
44
  }, 2000);
45
  }
46
  }
admin/html/menu.html CHANGED
@@ -839,29 +839,41 @@
839
  <div class="box">
840
  <h2><?php esc_html_e('Image Metadata', 'featured-image-from-url'); ?></h2>
841
  <div class="greybox">
842
- <?php esc_html_e('Most themes and plugins are not able to show the external Featured Image if there is no internal Featured Image associated to your post. Enabling the toggle below, symbolic empty files will be added to your Media Library to overcome this limitation.', 'featured-image-from-url'); ?>
843
  </div>
844
  <br>
845
- <form
846
- id="fifu_form_fake"
847
- action="javascript:void(0)"
848
- method="post">
849
- <input
850
- type="submit"
851
- href="javascript:void(0)"
852
- id="fifu_toggle_fake"
853
- onclick="invert('fake');
854
- fifu_fake_js();";
855
- name="fifu_toggle_fake"
856
- class="<?php echo $enable_fake; ?>"
857
- value=""
858
- style="display:block;border:none">
859
- <input
860
- type="hidden"
861
- id="fifu_input_fake"
862
- name="fifu_input_fake"
863
- value="" >
864
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
865
  </div>
866
 
867
  <div class="box">
@@ -908,37 +920,6 @@
908
  </table>
909
  </div>
910
 
911
- <div class="box">
912
- <div class="fifu-pro"><a href="https://fifu.app" target="_blank" style="color:grey">premium</a></div>
913
- <h2><?php esc_html_e('Schedule Metadata Generation', 'featured-image-from-url'); ?></h2>
914
- <div class="greybox" id="grad2">
915
- <?php esc_html_e('If you are setting the image URLs in a nonstandard way, the images probably won\'t be shown at front-end because some extra metadata is required. Here you can schedule an event to run each N minutes and check if there is some image URL without metadata and create that. The FIFU keys are listed on WP All Import > Custom Fields.', 'featured-image-from-url'); ?><br><br>
916
- <table style="text-align:left">
917
- <tr>
918
- <th>
919
- <label for="fifu_input_spinner_cron_metadata"
920
- placehold><?php esc_html_e('Interval (minutes)', 'featured-image-from-url'); ?></label>
921
- </th>
922
- <th>
923
- <input id="fifu_input_spinner_cron_metadata"
924
- name="fifu_input_spinner_cron_metadata"
925
- size="4">
926
- </th>
927
- <th>
928
- <input type="submit" value="<?php esc_html_e('Submit', 'featured-image-from-url'); ?>" disabled>
929
- </th>
930
- </tr>
931
- </table>
932
- </div>
933
- <br>
934
- <input
935
- type="submit"
936
- href="javascript:void(0)"
937
- class="toggleoff"
938
- value=""
939
- style="display:block;border:none">
940
- </div>
941
-
942
  <div class="box">
943
 
944
  <h2><?php esc_html_e('Save Image Dimensions', 'featured-image-from-url'); ?></h2>
@@ -978,6 +959,37 @@
978
  </table>
979
  </div>
980
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
981
  <div class="box">
982
  <h2><?php esc_html_e('Database', 'featured-image-from-url'); ?></h2>
983
  <div class="greybox">
@@ -2512,7 +2524,7 @@
2512
  <i class="fas fa-plug" style="font-size:30px"></i>
2513
  </td>
2514
  <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">
2515
- <i class="fas fa-laptop-code" style="font-size:30px"></i>
2516
  </td>
2517
  </tr>
2518
  <tr>
@@ -2523,7 +2535,7 @@
2523
  <i><?php esc_html_e('A famous plugin doesn\'t work with FIFU', 'featured-image-from-url'); ?></i>
2524
  </td>
2525
  <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">
2526
- <i><?php esc_html_e('I\'m a developer', 'featured-image-from-url'); ?></i>
2527
  </td>
2528
  </tr>
2529
  <tr>
@@ -2534,10 +2546,10 @@
2534
  <?php esc_html_e('3) enable Image Metadata.', 'featured-image-from-url'); ?>
2535
  </td>
2536
  <td style="vertical-align: top;">
2537
- <?php esc_html_e('Just send me an email. If you are available to discuss the details and the plugin is free and has more than 25,000 active installs, I should provide an integration very soon.', 'featured-image-from-url'); ?>
2538
  </td>
2539
  <td>
2540
- <?php esc_html_e('You can set Featured Images using custom fields. The main one is fifu_image_url and you can set that using REST API. For nonstandard automation you can call fifu_dev_set_image() or enable Schedule Metadata Generation.', 'featured-image-from-url'); ?>
2541
  </td>
2542
  </tr>
2543
  </table>
839
  <div class="box">
840
  <h2><?php esc_html_e('Image Metadata', 'featured-image-from-url'); ?></h2>
841
  <div class="greybox">
842
+ <?php esc_html_e('Generate the database registers that helps WordPress components to work with the external images.', 'featured-image-from-url'); ?>
843
  </div>
844
  <br>
845
+ <table>
846
+ <tr>
847
+ <th>
848
+ <form
849
+ id="fifu_form_fake"
850
+ action="javascript:void(0)"
851
+ method="post">
852
+ <input
853
+ type="submit"
854
+ href="javascript:void(0)"
855
+ id="fifu_toggle_fake"
856
+ onclick="invert('fake');
857
+ fifu_fake_js(false);";
858
+ name="fifu_toggle_fake"
859
+ class="<?php echo $enable_fake; ?>"
860
+ value=""
861
+ style="display:block;border:none">
862
+ <input
863
+ type="hidden"
864
+ id="fifu_input_fake"
865
+ name="fifu_input_fake"
866
+ value="" >
867
+ </form>
868
+ </th>
869
+ <th>
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 fifu_db_count_urls_without_metadata() ?></div>
874
+ </th>
875
+ </tr>
876
+ </table>
877
  </div>
878
 
879
  <div class="box">
920
  </table>
921
  </div>
922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
923
  <div class="box">
924
 
925
  <h2><?php esc_html_e('Save Image Dimensions', 'featured-image-from-url'); ?></h2>
959
  </table>
960
  </div>
961
 
962
+ <div class="box">
963
+ <div class="fifu-pro"><a href="https://fifu.app" target="_blank" style="color:grey">premium</a></div>
964
+ <h2><?php esc_html_e('Schedule Metadata Generation', 'featured-image-from-url'); ?></h2>
965
+ <div class="greybox" id="grad2">
966
+ <?php esc_html_e('If you are setting the image URLs in a nonstandard way, the images probably won\'t be shown at front-end because some extra metadata is required. Here you can schedule an event to run each N minutes and check if there is some image URL without metadata and create that. The FIFU keys are listed on WP All Import > Custom Fields.', 'featured-image-from-url'); ?><br><br>
967
+ <table style="text-align:left">
968
+ <tr>
969
+ <th>
970
+ <label for="fifu_input_spinner_cron_metadata"
971
+ placehold><?php esc_html_e('Interval (minutes)', 'featured-image-from-url'); ?></label>
972
+ </th>
973
+ <th>
974
+ <input id="fifu_input_spinner_cron_metadata"
975
+ name="fifu_input_spinner_cron_metadata"
976
+ size="4">
977
+ </th>
978
+ <th>
979
+ <input type="submit" value="<?php esc_html_e('Submit', 'featured-image-from-url'); ?>" disabled>
980
+ </th>
981
+ </tr>
982
+ </table>
983
+ </div>
984
+ <br>
985
+ <input
986
+ type="submit"
987
+ href="javascript:void(0)"
988
+ class="toggleoff"
989
+ value=""
990
+ style="display:block;border:none">
991
+ </div>
992
+
993
  <div class="box">
994
  <h2><?php esc_html_e('Database', 'featured-image-from-url'); ?></h2>
995
  <div class="greybox">
2524
  <i class="fas fa-plug" style="font-size:30px"></i>
2525
  </td>
2526
  <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">
2527
+ <i class="far fa-object-ungroup" style="font-size:30px"></i>
2528
  </td>
2529
  </tr>
2530
  <tr>
2535
  <i><?php esc_html_e('A famous plugin doesn\'t work with FIFU', 'featured-image-from-url'); ?></i>
2536
  </td>
2537
  <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">
2538
+ <i><?php esc_html_e('I\'m having style issues', 'featured-image-from-url'); ?></i>
2539
  </td>
2540
  </tr>
2541
  <tr>
2546
  <?php esc_html_e('3) enable Image Metadata.', 'featured-image-from-url'); ?>
2547
  </td>
2548
  <td style="vertical-align: top;">
2549
+ <?php esc_html_e('Just send me an email. If you are available to discuss the details and the plugin is free and has more than 10,000 active installs, I should provide an integration very soon.', 'featured-image-from-url'); ?>
2550
  </td>
2551
  <td>
2552
+ <?php esc_html_e('Some themes and plugins aren\'t responsive enough to work with external images. You may solve that running "Metadata > Save Image Dimensions."', 'featured-image-from-url'); ?>
2553
  </td>
2554
  </tr>
2555
  </table>
admin/html/meta-box.html CHANGED
@@ -103,7 +103,7 @@
103
  <td class="fifu-hover"><span title="Woocommerce image gallery" class="dashicons dashicons-format-gallery" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
104
  <td class="fifu-hover"><span title="Woocommerce video gallery" class="dashicons dashicons-format-video" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
105
  <td class="fifu-hover"><span title="Featured slider" class="dashicons dashicons-images-alt2" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
106
- <td class="fifu-hover"><span title="Featured shortcode" class="dashicons dashicons-editor-code" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
107
  </tr>
108
  </table>
109
  </div>
103
  <td class="fifu-hover"><span title="Woocommerce image gallery" class="dashicons dashicons-format-gallery" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
104
  <td class="fifu-hover"><span title="Woocommerce video gallery" class="dashicons dashicons-format-video" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
105
  <td class="fifu-hover"><span title="Featured slider" class="dashicons dashicons-images-alt2" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
106
+ <td class="fifu-hover"><span title="Featured shortcode" class="dashicons dashicons-shortcode" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
107
  </tr>
108
  </table>
109
  </div>
admin/menu.php CHANGED
@@ -228,10 +228,12 @@ function fifu_update_option($input, $type) {
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();
228
  }
229
  }
230
 
231
+ function fifu_enable_fake($savepoint) {
232
+ if (!$savepoint) {
233
+ if (get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
234
+ return;
235
+ update_option('fifu_fake_created', true, 'no');
236
+ }
237
 
238
  fifu_db_change_url_length();
239
  fifu_db_insert_attachment();
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
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.5
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
@@ -61,7 +61,7 @@ function fifu_activate_actions() {
61
  register_deactivation_hook(__FILE__, 'fifu_deactivation');
62
 
63
  function fifu_deactivation() {
64
- unlink(ABSPATH . 'fifu-lock');
65
  }
66
 
67
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
@@ -69,10 +69,9 @@ add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
69
  function fifu_upgrade($upgrader_object, $options) {
70
  $current_plugin_path_name = plugin_basename(__FILE__);
71
  if ($options['action'] == 'update' && $options['type'] == 'plugin') {
72
- foreach ($options['plugins'] as $each_plugin) {
73
  if ($each_plugin == $current_plugin_path_name) {
74
  fifu_activate_actions();
75
- unlink(ABSPATH . 'fifu-lock');
76
  }
77
  }
78
  }
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.6
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
61
  register_deactivation_hook(__FILE__, 'fifu_deactivation');
62
 
63
  function fifu_deactivation() {
64
+
65
  }
66
 
67
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
69
  function fifu_upgrade($upgrader_object, $options) {
70
  $current_plugin_path_name = plugin_basename(__FILE__);
71
  if ($options['action'] == 'update' && $options['type'] == 'plugin') {
72
+ foreach ((array) $options['plugins'] as $each_plugin) {
73
  if ($each_plugin == $current_plugin_path_name) {
74
  fifu_activate_actions();
 
75
  }
76
  }
77
  }
includes/attachment.php CHANGED
@@ -103,8 +103,33 @@ 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
  // fix zoom
107
- if ($image[1] == 1 && $image[2] == 1)
108
  $image[1] = 1920;
109
 
110
  return $image;
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;
109
+
110
+ return fifu_fix_dimensions($image, $size);
111
+ }
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']))
118
+ $image[1] = wp_get_registered_image_subsizes()[$size]['width'];
119
+
120
+ if (isset(wp_get_registered_image_subsizes()[$size]['height']))
121
+ $image[2] = wp_get_registered_image_subsizes()[$size]['height'];
122
+
123
+ if (isset(wp_get_registered_image_subsizes()[$size]['crop']))
124
+ $image[3] = wp_get_registered_image_subsizes()[$size]['crop'];
125
+ }
126
+ } else {
127
+ $image[1] = $size[0];
128
+ $image[2] = $size[1];
129
+ }
130
+
131
  // fix zoom
132
+ if (class_exists('WooCommerce') && is_product() && $image[1] == 1 && $image[2] == 1)
133
  $image[1] = 1920;
134
 
135
  return $image;
includes/html/js/image.js CHANGED
@@ -11,6 +11,11 @@ jQuery(document).ready(function ($) {
11
  setTimeout(function () {
12
  jQuery('img.zoomImg').css('z-index', '');
13
  }, 1000);
 
 
 
 
 
14
  });
15
 
16
  jQuery(window).on('ajaxComplete', function () {
11
  setTimeout(function () {
12
  jQuery('img.zoomImg').css('z-index', '');
13
  }, 1000);
14
+
15
+ jQuery('img[height=1]').each(function (index) {
16
+ if (jQuery(this).attr('width') != 1)
17
+ jQuery(this).css('position', 'relative');
18
+ });
19
  });
20
 
21
  jQuery(window).on('ajaxComplete', function () {
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: marceljm
3
  Donate link: https://donorbox.org/fifu
4
  Tags: featured image, featured, image, url, thumbnail
5
- Requires at least: 5.0
6
  Tested up to: 5.5
7
- Stable tag: 3.2.5
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.5 =
196
  * 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.
197
 
198
  = 3.2.4 =
199
  * Critical bug fix: conflict with URLs from Jetpack, Cloudinary and maybe others.
200
 
201
- = 3.2.3 =
202
- * Improvement: core changes for a better integration with themes, plugins and WordPress 5.5; bug fix: conflict between Hide Featured Media and Related Posts Thumbnails plugin.
203
-
204
  = others =
205
  * [more](https://fifu.app/changelog/)
206
 
207
 
208
  == Upgrade Notice ==
209
 
210
- = 3.2.5 =
211
- * 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.
2
  Contributors: marceljm
3
  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.6
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
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.6 =
211
+ * 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.