Featured Image From URL - Version 3.6.2

Version Description

  • Improvement: query optimizations (for sites with hundreds of thousands of URLs); improvement: CDN + Optimized Thumbnails (perfect image croppig for less style issues); improvement: Save Image Dimensions (150% faster, CLI integration); deprecated: CDN + Optimized Thumbnails > Shortpixel; fix: Lazy Load (conflict with AMP plugin).
Download this release

Release Info

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

Code changes from version 3.6.1 to 3.6.2

admin/api.php CHANGED
@@ -85,21 +85,21 @@ function fifu_api_query($dataset) {
85
  function fifu_enable_fake_api(WP_REST_Request $request) {
86
  update_option('fifu_fake_stop', false, 'no');
87
  fifu_enable_fake();
88
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
89
  return json_encode(array());
90
  }
91
 
92
  function fifu_disable_fake_api(WP_REST_Request $request) {
93
  update_option('fifu_fake_created', false, 'no');
94
  update_option('fifu_fake_stop', true, 'no');
95
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
96
  return json_encode(array());
97
  }
98
 
99
  function fifu_data_clean_api(WP_REST_Request $request) {
100
  fifu_db_enable_clean();
101
  update_option('fifu_data_clean', 'toggleoff', 'no');
102
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
103
  return json_encode(array());
104
  }
105
 
@@ -170,6 +170,64 @@ function fifu_api_list_all_without_dimensions(WP_REST_Request $request) {
170
  return fifu_db_get_all_without_dimensions();
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  function fifu_test_execution_time() {
174
  for ($i = 0; $i <= 120; $i++) {
175
  error_log($i);
@@ -212,13 +270,29 @@ add_action('rest_api_init', function () {
212
  register_rest_route('featured-image-from-url/v2', '/save_sizes_api/', array(
213
  'methods' => 'POST',
214
  'callback' => 'fifu_save_sizes_api',
215
- 'permission_callback' => 'fifu_get_private_data_permissions_check',
 
 
 
216
  ));
217
  register_rest_route('featured-image-from-url/v2', '/list_all_without_dimensions/', array(
218
  'methods' => 'POST',
219
  'callback' => 'fifu_api_list_all_without_dimensions',
220
  'permission_callback' => 'fifu_get_private_data_permissions_check',
221
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  register_rest_route('featured-image-from-url/v2', '/rest_url_api/', array(
223
  'methods' => ['GET', 'POST'],
224
  'callback' => 'fifu_rest_url',
85
  function fifu_enable_fake_api(WP_REST_Request $request) {
86
  update_option('fifu_fake_stop', false, 'no');
87
  fifu_enable_fake();
88
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
89
  return json_encode(array());
90
  }
91
 
92
  function fifu_disable_fake_api(WP_REST_Request $request) {
93
  update_option('fifu_fake_created', false, 'no');
94
  update_option('fifu_fake_stop', true, 'no');
95
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
96
  return json_encode(array());
97
  }
98
 
99
  function fifu_data_clean_api(WP_REST_Request $request) {
100
  fifu_db_enable_clean();
101
  update_option('fifu_data_clean', 'toggleoff', 'no');
102
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
103
  return json_encode(array());
104
  }
105
 
170
  return fifu_db_get_all_without_dimensions();
171
  }
172
 
173
+ function fifu_run_get_and_save_sizes_api(WP_REST_Request $request) {
174
+ $token = base64_encode(rand());
175
+ set_transient('fifu_token_for_get_and_save_sizes_api', $token, 3600 * 24 * 7);
176
+ $array_requests = array();
177
+ $results = fifu_db_get_all_without_dimensions();
178
+ $count = 1;
179
+ foreach ($results as $res) {
180
+ $url = $res->guid;
181
+ $array = array(
182
+ 'url' => esc_url_raw(rest_url()) . 'featured-image-from-url/v2/get_and_save_sizes_api/',
183
+ 'type' => 'POST',
184
+ 'headers' => [
185
+ 'Accept' => 'application/json'
186
+ ],
187
+ 'data' => json_encode([
188
+ 'att_id' => $res->ID,
189
+ 'url' => $url,
190
+ 'token' => $token
191
+ ]),
192
+ );
193
+ array_push($array_requests, $array);
194
+ if ($count % 10 == 0 || count($results) == $count) {
195
+ $requests = Requests::request_multiple($array_requests);
196
+ $array_requests = array();
197
+ $count = 1;
198
+ } else
199
+ $count++;
200
+ }
201
+ delete_transient('fifu_token_for_get_and_save_sizes_api');
202
+ }
203
+
204
+ function fifu_get_and_save_sizes_api(WP_REST_Request $request) {
205
+ $json = json_decode($request->get_Body());
206
+ $att_id = $json->att_id;
207
+ $token = $json->token;
208
+ $url = $json->url;
209
+ $imageSize = getImageSize($url);
210
+ $width = $imageSize[0];
211
+ $height = $imageSize[1];
212
+ $array = array(
213
+ 'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
214
+ 'body' => json_encode(
215
+ array(
216
+ 'att_id' => $att_id,
217
+ 'width' => $width,
218
+ 'height' => $height,
219
+ 'url' => $url,
220
+ 'token' => $token
221
+ )
222
+ ),
223
+ 'method' => 'POST',
224
+ 'data_format' => 'body',
225
+ 'blocking' => false,
226
+ 'timeout' => 10,
227
+ );
228
+ $response = fifu_remote_post(esc_url_raw(rest_url()) . 'featured-image-from-url/v2/save_sizes_api/', $array);
229
+ }
230
+
231
  function fifu_test_execution_time() {
232
  for ($i = 0; $i <= 120; $i++) {
233
  error_log($i);
270
  register_rest_route('featured-image-from-url/v2', '/save_sizes_api/', array(
271
  'methods' => 'POST',
272
  'callback' => 'fifu_save_sizes_api',
273
+ 'permission_callback' => function ($request) {
274
+ $json = json_decode($request->get_Body());
275
+ return get_transient('fifu_token_for_get_and_save_sizes_api') == $json->token;
276
+ },
277
  ));
278
  register_rest_route('featured-image-from-url/v2', '/list_all_without_dimensions/', array(
279
  'methods' => 'POST',
280
  'callback' => 'fifu_api_list_all_without_dimensions',
281
  'permission_callback' => 'fifu_get_private_data_permissions_check',
282
  ));
283
+ register_rest_route('featured-image-from-url/v2', '/run_get_and_save_sizes_api/', array(
284
+ 'methods' => 'POST',
285
+ 'callback' => 'fifu_run_get_and_save_sizes_api',
286
+ 'permission_callback' => 'fifu_get_private_data_permissions_check',
287
+ ));
288
+ register_rest_route('featured-image-from-url/v2', '/get_and_save_sizes_api/', array(
289
+ 'methods' => 'POST',
290
+ 'callback' => 'fifu_get_and_save_sizes_api',
291
+ 'permission_callback' => function ($request) {
292
+ $json = json_decode($request->get_Body());
293
+ return get_transient('fifu_token_for_get_and_save_sizes_api') == $json->token;
294
+ },
295
+ ));
296
  register_rest_route('featured-image-from-url/v2', '/rest_url_api/', array(
297
  'methods' => ['GET', 'POST'],
298
  'callback' => 'fifu_rest_url',
admin/cli-commands.php CHANGED
@@ -205,13 +205,13 @@ class fifu_cli extends WP_CLI_Command {
205
  case 'on':
206
  update_option('fifu_fake_stop', false, 'no');
207
  fifu_enable_fake();
208
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
209
  update_option('fifu_fake', 'toggleon', 'no'); // toggle
210
  break;
211
  case 'off':
212
  update_option('fifu_fake_created', false, 'no');
213
  update_option('fifu_fake_stop', true, 'no');
214
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
215
  update_option('fifu_fake', 'toggleoff', 'no'); // toggle
216
  break;
217
  }
@@ -220,7 +220,11 @@ class fifu_cli extends WP_CLI_Command {
220
  function clean() {
221
  fifu_db_enable_clean();
222
  update_option('fifu_data_clean', 'toggleoff', 'no');
223
- update_option('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 'no');
 
 
 
 
224
  }
225
 
226
  function db($args) {
205
  case 'on':
206
  update_option('fifu_fake_stop', false, 'no');
207
  fifu_enable_fake();
208
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
209
  update_option('fifu_fake', 'toggleon', 'no'); // toggle
210
  break;
211
  case 'off':
212
  update_option('fifu_fake_created', false, 'no');
213
  update_option('fifu_fake_stop', true, 'no');
214
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
215
  update_option('fifu_fake', 'toggleoff', 'no'); // toggle
216
  break;
217
  }
220
  function clean() {
221
  fifu_db_enable_clean();
222
  update_option('fifu_data_clean', 'toggleoff', 'no');
223
+ set_transient('fifu_image_metadata_counter', fifu_db_count_urls_without_metadata(), 0);
224
+ }
225
+
226
+ function dimensions() {
227
+ fifu_run_get_and_save_sizes_api(new WP_REST_Request());
228
  }
229
 
230
  function db($args) {
admin/db.php CHANGED
@@ -64,16 +64,12 @@ class FifuDb {
64
  $this->wpdb->get_results("
65
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
66
  SELECT p.id, '_wp_attached_file', p.guid
67
- FROM " . $this->posts . " p
68
- WHERE p.post_parent IN (" . $ids . ")
 
69
  AND p.post_type = 'attachment'
70
  AND p.post_author = " . $this->author . "
71
  " . $ctgr_sql . "
72
- AND NOT EXISTS (
73
- SELECT 1
74
- FROM (SELECT post_id FROM " . $this->postmeta . " WHERE meta_key = '_wp_attached_file') AS b
75
- WHERE p.id = b.post_id
76
- )
77
  )"
78
  );
79
  }
@@ -107,16 +103,12 @@ class FifuDb {
107
  $this->wpdb->get_results("
108
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
109
  SELECT p.id, '_wp_attachment_image_alt', p.post_title
110
- FROM " . $this->posts . " p
111
- WHERE p.post_parent IN (" . $ids . ")
 
112
  AND p.post_type = 'attachment'
113
  AND p.post_author = " . $this->author . "
114
  " . $ctgr_sql . "
115
- AND NOT EXISTS (
116
- SELECT 1
117
- FROM (SELECT post_id FROM " . $this->postmeta . " WHERE meta_key = '_wp_attachment_image_alt') AS b
118
- WHERE p.id = b.post_id
119
- )
120
  )"
121
  );
122
  }
@@ -128,16 +120,12 @@ class FifuDb {
128
  $this->wpdb->get_results("
129
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
130
  SELECT p.post_parent, '_thumbnail_id', p.id
131
- FROM " . $this->posts . " p
132
- WHERE p.post_parent IN (" . $ids . ")
 
133
  AND p.post_type = 'attachment'
134
  AND p.post_author = " . $this->author . "
135
  " . $ctgr_sql . "
136
- AND NOT EXISTS (
137
- SELECT 1
138
- FROM (SELECT post_id FROM " . $this->postmeta . " WHERE meta_key = '_thumbnail_id') AS b
139
- WHERE p.post_parent = b.post_id
140
- )
141
  )"
142
  );
143
  }
@@ -236,15 +224,11 @@ class FifuDb {
236
  function get_posts_without_dimensions() {
237
  return $this->wpdb->get_results("
238
  SELECT p.ID, p.guid
239
- FROM " . $this->posts . " p
240
- WHERE p.post_type = 'attachment'
 
241
  AND p.post_author = " . $this->author . "
242
  AND p.post_status NOT IN ('auto-draft', 'trash')
243
- AND NOT EXISTS (
244
- SELECT 1
245
- FROM (SELECT post_id FROM " . $this->postmeta . " WHERE meta_key = '_wp_attachment_metadata') AS b
246
- WHERE p.id = b.post_id
247
- )
248
  ORDER BY p.id DESC"
249
  );
250
  }
@@ -253,15 +237,10 @@ class FifuDb {
253
  function get_count_posts_without_dimensions() {
254
  return $this->wpdb->get_results("
255
  SELECT COUNT(1) AS amount
256
- FROM " . $this->posts . " p
257
- WHERE p.post_type = 'attachment'
258
- AND p.post_author = " . $this->author . "
259
- AND NOT EXISTS (
260
- SELECT 1
261
- FROM " . $this->postmeta . " pm
262
- WHERE p.id = pm.post_id
263
- AND pm.meta_key = '_wp_attachment_metadata'
264
- )"
265
  );
266
  }
267
 
@@ -635,7 +614,7 @@ class FifuDb {
635
  $this->insert_thumbnail_id($ids, false);
636
  $this->insert_attachment_meta_url($ids, false);
637
  $this->insert_attachment_meta_alt($ids, false);
638
- update_option('fifu_image_metadata_counter', $total - $count, 'no');
639
  if (get_option('fifu_fake_stop'))
640
  return;
641
  $ids = null;
@@ -947,6 +926,11 @@ function fifu_db_clean_dimensions_all() {
947
 
948
  function fifu_db_missing_dimensions() {
949
  $db = new FifuDb();
 
 
 
 
 
950
  $aux = $db->get_count_posts_without_dimensions()[0];
951
  return $aux ? $aux->amount : -1;
952
  }
64
  $this->wpdb->get_results("
65
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
66
  SELECT p.id, '_wp_attached_file', p.guid
67
+ FROM " . $this->posts . " p LEFT OUTER JOIN " . $this->postmeta . " b ON p.id = b.post_id AND meta_key = '_wp_attached_file'
68
+ WHERE b.post_id IS NULL
69
+ AND p.post_parent IN (" . $ids . ")
70
  AND p.post_type = 'attachment'
71
  AND p.post_author = " . $this->author . "
72
  " . $ctgr_sql . "
 
 
 
 
 
73
  )"
74
  );
75
  }
103
  $this->wpdb->get_results("
104
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
105
  SELECT p.id, '_wp_attachment_image_alt', p.post_title
106
+ FROM " . $this->posts . " p LEFT OUTER JOIN " . $this->postmeta . " b ON p.id = b.post_id AND meta_key = '_wp_attachment_image_alt'
107
+ WHERE b.post_id IS NULL
108
+ AND p.post_parent IN (" . $ids . ")
109
  AND p.post_type = 'attachment'
110
  AND p.post_author = " . $this->author . "
111
  " . $ctgr_sql . "
 
 
 
 
 
112
  )"
113
  );
114
  }
120
  $this->wpdb->get_results("
121
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
122
  SELECT p.post_parent, '_thumbnail_id', p.id
123
+ FROM " . $this->posts . " p LEFT OUTER JOIN " . $this->postmeta . " b ON p.post_parent = b.post_id AND meta_key = '_thumbnail_id'
124
+ WHERE b.post_id IS NULL
125
+ AND p.post_parent IN (" . $ids . ")
126
  AND p.post_type = 'attachment'
127
  AND p.post_author = " . $this->author . "
128
  " . $ctgr_sql . "
 
 
 
 
 
129
  )"
130
  );
131
  }
224
  function get_posts_without_dimensions() {
225
  return $this->wpdb->get_results("
226
  SELECT p.ID, p.guid
227
+ FROM " . $this->posts . " p LEFT OUTER JOIN " . $this->postmeta . " b ON p.id = b.post_id AND meta_key = '_wp_attachment_metadata'
228
+ WHERE b.post_id IS NULL
229
+ AND p.post_type = 'attachment'
230
  AND p.post_author = " . $this->author . "
231
  AND p.post_status NOT IN ('auto-draft', 'trash')
 
 
 
 
 
232
  ORDER BY p.id DESC"
233
  );
234
  }
237
  function get_count_posts_without_dimensions() {
238
  return $this->wpdb->get_results("
239
  SELECT COUNT(1) AS amount
240
+ FROM " . $this->posts . " p LEFT OUTER JOIN " . $this->postmeta . " b ON p.id = b.post_id AND meta_key = '_wp_attachment_metadata'
241
+ WHERE b.post_id IS NULL
242
+ AND p.post_type = 'attachment'
243
+ AND p.post_author = " . $this->author
 
 
 
 
 
244
  );
245
  }
246
 
614
  $this->insert_thumbnail_id($ids, false);
615
  $this->insert_attachment_meta_url($ids, false);
616
  $this->insert_attachment_meta_alt($ids, false);
617
+ set_transient('fifu_image_metadata_counter', $total - $count, 0);
618
  if (get_option('fifu_fake_stop'))
619
  return;
620
  $ids = null;
926
 
927
  function fifu_db_missing_dimensions() {
928
  $db = new FifuDb();
929
+
930
+ // too much
931
+ if (fifu_db_count_urls_with_metadata() > 10000)
932
+ return -1;
933
+
934
  $aux = $db->get_count_posts_without_dimensions()[0];
935
  return $aux ? $aux->amount : -1;
936
  }
admin/html/js/menu.js CHANGED
@@ -223,66 +223,41 @@ function fifu_run_delete_all_js() {
223
  }
224
 
225
  function fifu_save_dimensions_all_js() {
 
 
 
 
 
 
 
226
  jQuery('#tabs-top').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
227
 
 
 
 
 
228
  jQuery.ajax({
229
  method: "POST",
230
- url: restUrl + 'featured-image-from-url/v2/list_all_without_dimensions/',
231
  async: true,
232
  beforeSend: function (xhr) {
233
  xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
234
  },
235
  success: function (data) {
236
- var i = 0;
237
- var count = data.length;
238
-
239
- function dimensionsLoop(data, i) {
240
- var attempts = 0;
241
- var image = new Image();
242
- jQuery(image).attr('src', data[i]['guid']);
243
- is_svg = data[i]['guid'].includes('.svg');
244
-
245
- var poll = setInterval(function () {
246
- if (image.naturalWidth || attempts > 100 || is_svg) {
247
- attempts = 0;
248
- clearInterval(poll);
249
- if (!is_svg)
250
- fifu_get_sizes(image, data[i]['ID'], data[i]['guid']);
251
- image = null;
252
- i++;
253
- if (i < data.length) {
254
- jQuery("#countdown").text(parseInt(jQuery("#countdown").text()) - 1)
255
- dimensionsLoop(data, i);
256
- } else {
257
- jQuery('#tabs-top').unblock();
258
- invert('save_dimensions_all');
259
- jQuery("#countdown").text('done');
260
- }
261
- } else {
262
- console.log(data[i]['guid']);
263
- attempts++;
264
- }
265
- }, 25);
266
- }
267
-
268
- if (data.length > 0) {
269
- dimensionsLoop(data, i);
270
- } else {
271
- jQuery('#tabs-top').unblock();
272
- invert('save_dimensions_all');
273
- jQuery("#countdown").text('done');
274
- }
275
  },
276
  error: function (jqXHR, textStatus, errorThrown) {
277
  console.log(jqXHR);
278
  console.log(textStatus);
279
  console.log(errorThrown);
 
 
280
  setTimeout(function () {
281
- fifu_save_dimensions_all_js();
 
282
  }, 1000);
283
  },
284
- complete: function (data) {
285
- },
286
  timeout: 0
287
  });
288
  }
223
  }
224
 
225
  function fifu_save_dimensions_all_js() {
226
+ tooMany = '(it will take too much time. Please contact the support for a better solution)';
227
+ if (parseInt(jQuery("#countdown").text()) == -1 || jQuery("#countdown").text() == tooMany) {
228
+ jQuery("#countdown").text(tooMany);
229
+ invert('save_dimensions_all');
230
+ return;
231
+ }
232
+
233
  jQuery('#tabs-top').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
234
 
235
+ interval = setInterval(function () {
236
+ jQuery("#countdown").load(location.href + " #countdown");
237
+ }, 3000);
238
+
239
  jQuery.ajax({
240
  method: "POST",
241
+ url: restUrl + 'featured-image-from-url/v2/run_get_and_save_sizes_api/',
242
  async: true,
243
  beforeSend: function (xhr) {
244
  xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
245
  },
246
  success: function (data) {
247
+ jQuery("#countdown").load(location.href + " #countdown");
248
+ clearInterval(interval);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  },
250
  error: function (jqXHR, textStatus, errorThrown) {
251
  console.log(jqXHR);
252
  console.log(textStatus);
253
  console.log(errorThrown);
254
+ },
255
+ complete: function () {
256
  setTimeout(function () {
257
+ invert('save_dimensions_all');
258
+ jQuery('#tabs-top').unblock();
259
  }, 1000);
260
  },
 
 
261
  timeout: 0
262
  });
263
  }
admin/html/menu.html CHANGED
@@ -1462,6 +1462,20 @@
1462
  <th>
1463
  </th>
1464
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1465
  <tr class="color">
1466
  <th>
1467
  <?php $fifu['tab']['metadata']() ?>
@@ -1509,21 +1523,6 @@
1509
  100, 1000, 5000...
1510
  </th>
1511
  </tr>
1512
- <tr class="color">
1513
- <th>
1514
- <?php $fifu['tab']['performance']() ?>
1515
- </th>
1516
- <th>
1517
- <?php $fifu['title']['jetpack']() ?>
1518
- </th>
1519
- <th>Shortpixel</th>
1520
- <th>
1521
- wp fifu shortpixel &lt;toggle&gt;
1522
- </th>
1523
- <th>
1524
- on, off
1525
- </th>
1526
- </tr>
1527
  <tr class="color">
1528
  <th>
1529
  <?php $fifu['tab']['performance']() ?>
@@ -2901,7 +2900,7 @@
2901
  <?php $fifu['metadata']['generate']() ?>
2902
  </th>
2903
  <th>
2904
- <div id="image_metadata_counter"><?php echo get_option('fifu_image_metadata_counter') ?></div>
2905
  </th>
2906
  </tr>
2907
  </table>
@@ -3958,7 +3957,6 @@
3958
  <div id="tabsCDN">
3959
  <ul>
3960
  <li><a href="#tabs-1">Jetpack</a></li>
3961
- <li><a href="#tabs-2">ShortPixel (beta)</a></li>
3962
  </ul>
3963
  <div id="tabs-1">
3964
  <div class="greybox">
@@ -3974,24 +3972,6 @@
3974
 
3975
  </div>
3976
  </div>
3977
- <div id="tabs-2">
3978
- <div class="fifu-pro" style="position: relative; top: -40px;"><div class="fifu-pro-out"><a class="fifu-pro-link" href="https://fifu.app/" target="_blank" title="Unlock all features"><h4 class="fifu-pro-text"><span class="dashicons dashicons-lock fifu-pro-icon"></span>PRO</h4></a></div></div>
3979
- <div class="greybox" id="grad2">
3980
-
3981
- <?php $fifu['shortpixel']['desc']() ?><br><br>
3982
- <b><?php $fifu['detail']['requirement']() ?></b>: <?php $fifu['flickr']['important']() ?>
3983
-
3984
- </div>
3985
-
3986
- <br>
3987
-
3988
- <input
3989
- type="submit"
3990
- href="javascript:void(0)"
3991
- class="toggleoff"
3992
- value=""
3993
- style="display:block;border:none">
3994
- </div>
3995
  </div>
3996
  </div>
3997
 
1462
  <th>
1463
  </th>
1464
  </tr>
1465
+ <tr class="color">
1466
+ <th>
1467
+ <?php $fifu['tab']['metadata']() ?>
1468
+ </th>
1469
+ <th>
1470
+ <?php $fifu['title']['dimensions']() ?>
1471
+ </th>
1472
+ <th></th>
1473
+ <th>
1474
+ wp fifu dimensions
1475
+ </th>
1476
+ <th>
1477
+ </th>
1478
+ </tr>
1479
  <tr class="color">
1480
  <th>
1481
  <?php $fifu['tab']['metadata']() ?>
1523
  100, 1000, 5000...
1524
  </th>
1525
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1526
  <tr class="color">
1527
  <th>
1528
  <?php $fifu['tab']['performance']() ?>
2900
  <?php $fifu['metadata']['generate']() ?>
2901
  </th>
2902
  <th>
2903
+ <div id="image_metadata_counter"><?php echo get_transient('fifu_image_metadata_counter') ?></div>
2904
  </th>
2905
  </tr>
2906
  </table>
3957
  <div id="tabsCDN">
3958
  <ul>
3959
  <li><a href="#tabs-1">Jetpack</a></li>
 
3960
  </ul>
3961
  <div id="tabs-1">
3962
  <div class="greybox">
3972
 
3973
  </div>
3974
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3975
  </div>
3976
  </div>
3977
 
admin/strings.php CHANGED
@@ -385,13 +385,13 @@ function fifu_get_strings_settings() {
385
  _e("PageSpeed and GTmetrix issues", FIFU_SLUG);
386
  };
387
  $fifu['support']['disappeared-desc'] = function() {
388
- _e("You were probably using a deprecated feature. Just do it: 1) access Metadata tab; 2) run Clean Metadata; 3) enable Image Metadata (~30,000 URLs/min); 4) clean your cache (optional).", FIFU_SLUG);
389
  };
390
  $fifu['support']['plugin-desc'] = function() {
391
  _e("Just send us an email. If you are available to discuss the details and the plugin is free and has more than 10,000 active installs, we should provide an integration very soon.", FIFU_SLUG);
392
  };
393
  $fifu['support']['style-desc'] = function() {
394
- _e("Some themes and plugins aren't responsive enough to work with external images. You may solve that running Metadata > Save Image Dimensions (~60 URLs/min).", FIFU_SLUG);
395
  };
396
  $fifu['support']['facebook-desc'] = function() {
397
  _e("You probably have a plugin or theme that sets a default image as the Facebook image (og:image tag). Just find and disable the option.", FIFU_SLUG);
@@ -822,7 +822,7 @@ function fifu_get_strings_settings() {
822
 
823
  // dimensions
824
  $fifu['dimensions']['desc'] = function() {
825
- _e("Some themes and plugins may not work correctly without image dimensions. This feature can get ~1 image dimension by second.", FIFU_SLUG);
826
  };
827
  $fifu['dimensions']['now'] = function() {
828
  _e("save the dimensions of all featured images now", FIFU_SLUG);
@@ -830,7 +830,7 @@ function fifu_get_strings_settings() {
830
 
831
  // schedule
832
  $fifu['schedule']['desc'] = function() {
833
- _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.", FIFU_SLUG);
834
  };
835
  $fifu['schedule']['interval'] = function() {
836
  _e("Interval (minutes)", FIFU_SLUG);
@@ -865,9 +865,6 @@ function fifu_get_strings_settings() {
865
  $fifu['jetpack']['requirement'] = function() {
866
  _e("FIFU Lazy Load feature should be enabled.", FIFU_SLUG);
867
  };
868
- $fifu['shortpixel']['desc'] = function() {
869
- _e("ShortPixel CDN is being tested as an alternative to Jetpack. You don't need to install any plugins to use this CDN.", FIFU_SLUG);
870
- };
871
 
872
  // lazy
873
  $fifu['lazy']['desc'] = function() {
385
  _e("PageSpeed and GTmetrix issues", FIFU_SLUG);
386
  };
387
  $fifu['support']['disappeared-desc'] = function() {
388
+ _e("You were probably using a deprecated feature. Just do it: 1) access Metadata tab; 2) run Clean Metadata; 3) enable Image Metadata (~50,000 URLs/min); 4) clean your cache (optional).", FIFU_SLUG);
389
  };
390
  $fifu['support']['plugin-desc'] = function() {
391
  _e("Just send us an email. If you are available to discuss the details and the plugin is free and has more than 10,000 active installs, we should provide an integration very soon.", FIFU_SLUG);
392
  };
393
  $fifu['support']['style-desc'] = function() {
394
+ _e("Some themes and plugins aren't responsive enough to work with external images. You may solve that running Metadata > Save Image Dimensions (~150 URLs/min).", FIFU_SLUG);
395
  };
396
  $fifu['support']['facebook-desc'] = function() {
397
  _e("You probably have a plugin or theme that sets a default image as the Facebook image (og:image tag). Just find and disable the option.", FIFU_SLUG);
822
 
823
  // dimensions
824
  $fifu['dimensions']['desc'] = function() {
825
+ _e("Some themes and plugins may not work correctly without image dimensions. This feature can get the dimensions of ~150 images by minute.", FIFU_SLUG);
826
  };
827
  $fifu['dimensions']['now'] = function() {
828
  _e("save the dimensions of all featured images now", FIFU_SLUG);
830
 
831
  // schedule
832
  $fifu['schedule']['desc'] = function() {
833
+ _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 REST API > Custom Fields.", FIFU_SLUG);
834
  };
835
  $fifu['schedule']['interval'] = function() {
836
  _e("Interval (minutes)", FIFU_SLUG);
865
  $fifu['jetpack']['requirement'] = function() {
866
  _e("FIFU Lazy Load feature should be enabled.", FIFU_SLUG);
867
  };
 
 
 
868
 
869
  // lazy
870
  $fifu['lazy']['desc'] = function() {
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.6.1
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
11
- * WC tested up to: 5.3
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.6.2
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
11
+ * WC tested up to: 5.4
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
@@ -53,10 +53,8 @@ add_filter('posts_where', 'fifu_query_attachments');
53
 
54
  function fifu_query_attachments($where) {
55
  global $wpdb;
56
- if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments') && true) {
57
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
58
- } else
59
- $where .= ' AND (' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' OR (' . $wpdb->prefix . 'posts.post_author = ' . FIFU_AUTHOR . ' AND EXISTS (SELECT 1 FROM ' . $wpdb->prefix . 'postmeta WHERE ' . $wpdb->prefix . 'postmeta.post_id = ' . $wpdb->prefix . 'posts.id AND ' . $wpdb->prefix . 'postmeta.meta_key = "_wp_attachment_metadata")))';
60
  return $where;
61
  }
62
 
@@ -64,8 +62,6 @@ add_filter('posts_where', function ($where, \WP_Query $q) {
64
  global $wpdb;
65
  if (is_admin() && $q->is_main_query() && true)
66
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
67
- else
68
- $where .= ' AND (' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' OR (' . $wpdb->prefix . 'posts.post_author = ' . FIFU_AUTHOR . ' AND EXISTS (SELECT 1 FROM ' . $wpdb->prefix . 'postmeta WHERE ' . $wpdb->prefix . 'postmeta.post_id = ' . $wpdb->prefix . 'posts.id AND ' . $wpdb->prefix . 'postmeta.meta_key = "_wp_attachment_metadata")))';
69
  return $where;
70
  }, 10, 2);
71
 
@@ -129,7 +125,7 @@ function fifu_fix_dimensions($image, $size) {
129
  // default
130
  $image = fifu_add_size($image, $size);
131
 
132
- // fix zoom
133
  if (class_exists('WooCommerce') && is_product() && $image[1] == 1 && $image[2] == 1)
134
  $image[1] = 1920;
135
 
@@ -163,18 +159,8 @@ function fifu_add_size($image, $size) {
163
  if (!$width && !$height)
164
  return $image;
165
 
166
- // skip
167
- if ($image[1] > 1) {
168
- // default height
169
- if ($height == 9999)
170
- return $image;
171
- // aspect ratio
172
- if ($image[2] != 0 && $height != 0 && abs($image[1] / $image[2] - $width / $height) > 0.1)
173
- return $image;
174
- }
175
-
176
  $image[1] = $width;
177
- $image[2] = $height;
178
  $image[3] = $crop;
179
  }
180
  } else {
@@ -189,15 +175,27 @@ function fifu_get_photon_url($image, $size, $att_id) {
189
  $w = $image[1];
190
  $h = $image[2];
191
 
 
 
 
192
  $args = array();
193
 
194
- if ($w > 0) {
195
- $args['w'] = $w;
196
- $args['resize'] = array($w, null);
 
 
 
 
 
 
 
197
  }
198
 
199
- if (fifu_debug_jetpack())
200
- define('IS_WPCOM', true);
 
 
201
 
202
  $image[0] = jetpack_photon_url($image[0], $args, null);
203
  $image[0] = fifu_process_external_url($image[0], $att_id, $size);
53
 
54
  function fifu_query_attachments($where) {
55
  global $wpdb;
56
+ if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments'))
57
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
 
 
58
  return $where;
59
  }
60
 
62
  global $wpdb;
63
  if (is_admin() && $q->is_main_query() && true)
64
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
 
 
65
  return $where;
66
  }, 10, 2);
67
 
125
  // default
126
  $image = fifu_add_size($image, $size);
127
 
128
+ // fix gallery (but no zoom or lightbox)
129
  if (class_exists('WooCommerce') && is_product() && $image[1] == 1 && $image[2] == 1)
130
  $image[1] = 1920;
131
 
159
  if (!$width && !$height)
160
  return $image;
161
 
 
 
 
 
 
 
 
 
 
 
162
  $image[1] = $width;
163
+ $image[2] = $height == 9999 ? null : $height;
164
  $image[3] = $crop;
165
  }
166
  } else {
175
  $w = $image[1];
176
  $h = $image[2];
177
 
178
+ if (fifu_debug_jetpack())
179
+ define('IS_WPCOM', true);
180
+
181
  $args = array();
182
 
183
+ if ($w > 0 && $h > 0) {
184
+ $args['resize'] = array($w, $h);
185
+ } elseif ($w > 0) {
186
+ $args['resize'] = array($w);
187
+ $args['w'] = array($w);
188
+ } elseif ($h > 0) {
189
+ $args['resize'] = array($h);
190
+ $args['h'] = array($h);
191
+ } else {
192
+
193
  }
194
 
195
+ // Remove CDN prefix
196
+ $matches = preg_split('/https:\/\//', $image[0]);
197
+ if ($matches && count($matches) > 2)
198
+ $image[0] = str_replace('https://' . $matches[1], '', $image[0]);
199
 
200
  $image[0] = jetpack_photon_url($image[0], $args, null);
201
  $image[0] = fifu_process_external_url($image[0], $att_id, $size);
includes/thumbnail.php CHANGED
@@ -120,7 +120,7 @@ function fifu_replace($html, $post_id, $post_thumbnail_id, $size, $attr) {
120
  $alt = null;
121
  }
122
 
123
- if (fifu_is_on('fifu_lazy') && !is_admin()) {
124
  if (fifu_is_avada_active()) {
125
  if (strpos($html, ' src=') !== false && strpos($html, ' data-srcset=') === false)
126
  $html = str_replace(" src=", " data-srcset=", $html);
120
  $alt = null;
121
  }
122
 
123
+ if (fifu_is_on('fifu_lazy') && !is_admin() && !fifu_is_amp_active()) {
124
  if (fifu_is_avada_active()) {
125
  if (strpos($html, ' src=') !== false && strpos($html, ' data-srcset=') === false)
126
  $html = str_replace(" src=", " data-srcset=", $html);
includes/util.php CHANGED
@@ -128,6 +128,10 @@ function fifu_is_bbpress_active() {
128
  return is_plugin_active('bbpress/bbpress.php');
129
  }
130
 
 
 
 
 
131
  // active themes
132
 
133
  function fifu_is_flatsome_active() {
128
  return is_plugin_active('bbpress/bbpress.php');
129
  }
130
 
131
+ function fifu_is_amp_active() {
132
+ return is_plugin_active('amp/amp.php');
133
+ }
134
+
135
  // active themes
136
 
137
  function fifu_is_flatsome_active() {
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://donorbox.org/fifu
4
- Tags: featured, image, url, video, thumbnail
5
  Requires at least: 5.3
6
  Tested up to: 5.7
7
- Stable tag: 3.6.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -152,7 +152,7 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr, Publitio,
152
 
153
  = What's the metadata created by FIFU?
154
 
155
- * Database registers that help WordPress components to work with the external images. FIFU can generate the metadata of ~30,000 image URLs per minute.
156
 
157
  = What are the disadvantages of the external images?
158
 
@@ -208,6 +208,9 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr, Publitio,
208
 
209
  == Changelog ==
210
 
 
 
 
211
  = 3.6.1 =
212
  * New: FIFU widgets for WordPress and Elementor.
213
 
@@ -223,5 +226,5 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr, Publitio,
223
 
224
  == Upgrade Notice ==
225
 
226
- = 3.6.1 =
227
- * New: FIFU widgets for WordPress and Elementor.
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://donorbox.org/fifu
4
+ Tags: featured, image, url, video, woocommerce
5
  Requires at least: 5.3
6
  Tested up to: 5.7
7
+ Stable tag: 3.6.2
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
152
 
153
  = What's the metadata created by FIFU?
154
 
155
+ * Database registers that help WordPress components to work with the external images. FIFU can generate the metadata of ~50,000 image URLs per minute.
156
 
157
  = What are the disadvantages of the external images?
158
 
208
 
209
  == Changelog ==
210
 
211
+ = 3.6.2 =
212
+ * Improvement: query optimizations (for sites with hundreds of thousands of URLs); improvement: CDN + Optimized Thumbnails (perfect image croppig for less style issues); improvement: Save Image Dimensions (150% faster, CLI integration); deprecated: CDN + Optimized Thumbnails > Shortpixel; fix: Lazy Load (conflict with AMP plugin).
213
+
214
  = 3.6.1 =
215
  * New: FIFU widgets for WordPress and Elementor.
216
 
226
 
227
  == Upgrade Notice ==
228
 
229
+ = 3.6.2 =
230
+ * Improvement: query optimizations (for sites with hundreds of thousands of URLs); improvement: CDN + Optimized Thumbnails (perfect image croppig for less style issues); improvement: Save Image Dimensions (150% faster, CLI integration); deprecated: CDN + Optimized Thumbnails > Shortpixel; fix: Lazy Load (conflict with AMP plugin).