Featured Image From URL - Version 2.5.5

Version Description

  • Improvements: option to show/hide external images in media library; option to clean image dimensions.
Download this release

Release Info

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

Code changes from version 2.5.4 to 2.5.5

admin/api.php CHANGED
@@ -30,6 +30,15 @@ function fifu_save_dimensions_all_api(WP_REST_Request $request) {
30
  fifu_db_save_dimensions_all();
31
  }
32
 
 
 
 
 
 
 
 
 
 
33
  function fifu_test_execution_time() {
34
  for ($i = 0; $i <= 120; $i++) {
35
  error_log($i);
@@ -58,5 +67,9 @@ add_action('rest_api_init', function () {
58
  'methods' => 'POST',
59
  'callback' => 'fifu_save_dimensions_all_api'
60
  ));
 
 
 
 
61
  });
62
 
30
  fifu_db_save_dimensions_all();
31
  }
32
 
33
+ function fifu_clean_dimensions_all_api(WP_REST_Request $request) {
34
+ update_option('fifu_clean_dimensions_all', 'toggleoff', 'no');
35
+
36
+ if (fifu_is_off('fifu_clean_dimensions'))
37
+ return;
38
+
39
+ fifu_db_clean_dimensions_all();
40
+ }
41
+
42
  function fifu_test_execution_time() {
43
  for ($i = 0; $i <= 120; $i++) {
44
  error_log($i);
67
  'methods' => 'POST',
68
  'callback' => 'fifu_save_dimensions_all_api'
69
  ));
70
+ register_rest_route('featured-image-from-url/v2', '/clean_dimensions_all_api/', array(
71
+ 'methods' => 'POST',
72
+ 'callback' => 'fifu_clean_dimensions_all_api'
73
+ ));
74
  });
75
 
admin/db.php CHANGED
@@ -194,19 +194,14 @@ class FifuDb {
194
  return $this->wpdb->get_results("
195
  SELECT *
196
  FROM " . $this->posts . " p
197
- WHERE p.post_type IN ('$this->types')
 
198
  AND post_status NOT IN ('auto-draft', 'trash')
199
- AND EXISTS (
200
  SELECT 1
201
  FROM " . $this->postmeta . " pm
202
  WHERE p.id = pm.post_id
203
- AND pm.meta_key IN ('fifu_image_url')
204
- )
205
- AND NOT EXISTS (
206
- SELECT 1
207
- FROM " . $this->postmeta . " pm2
208
- WHERE p.id = pm2.post_id
209
- AND pm2.meta_key IN ('fifu_image_dimension')
210
  )
211
  ORDER BY p.ID"
212
  );
@@ -605,7 +600,7 @@ class FifuDb {
605
  $post_id = $res->ID;
606
 
607
  // set featured image
608
- $url = fifu_main_image_url($post_id);
609
 
610
  if (!$url) {
611
  $count++;
@@ -633,6 +628,15 @@ class FifuDb {
633
  }
634
  }
635
 
 
 
 
 
 
 
 
 
 
636
  /* save 1 post */
637
 
638
  function update_fake_attach_id($post_id) {
@@ -650,11 +654,7 @@ class FifuDb {
650
  if (fifu_get_default_url())
651
  set_post_thumbnail($post_id, get_option('fifu_default_attach_id'));
652
  }
653
- }
654
- else {
655
- if (fifu_is_on('fifu_save_dimensions'))
656
- fifu_save_dimensions($post_id, $url);
657
-
658
  // update
659
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
660
  if ($has_fifu_attachment) {
@@ -676,6 +676,8 @@ class FifuDb {
676
  $this->delete_attachment_meta_url_and_alt($attachments);
677
  }
678
  }
 
 
679
  }
680
  }
681
 
@@ -856,6 +858,13 @@ function fifu_db_save_dimensions_all() {
856
  return $db->save_dimensions_all();
857
  }
858
 
 
 
 
 
 
 
 
859
  /* clean metadata */
860
 
861
  function fifu_db_enable_clean() {
194
  return $this->wpdb->get_results("
195
  SELECT *
196
  FROM " . $this->posts . " p
197
+ WHERE p.post_type = 'attachment'
198
+ AND post_author = " . $this->author . "
199
  AND post_status NOT IN ('auto-draft', 'trash')
200
+ AND NOT EXISTS (
201
  SELECT 1
202
  FROM " . $this->postmeta . " pm
203
  WHERE p.id = pm.post_id
204
+ AND pm.meta_key IN ('fifu_image_dimension')
 
 
 
 
 
 
205
  )
206
  ORDER BY p.ID"
207
  );
600
  $post_id = $res->ID;
601
 
602
  // set featured image
603
+ $url = $res->guid;
604
 
605
  if (!$url) {
606
  $count++;
628
  }
629
  }
630
 
631
+ /* dimensions: clean all */
632
+
633
+ function clean_dimensions_all() {
634
+ $this->wpdb->get_results("
635
+ DELETE FROM " . $this->postmeta . "
636
+ WHERE meta_key = 'fifu_image_dimension'"
637
+ );
638
+ }
639
+
640
  /* save 1 post */
641
 
642
  function update_fake_attach_id($post_id) {
654
  if (fifu_get_default_url())
655
  set_post_thumbnail($post_id, get_option('fifu_default_attach_id'));
656
  }
657
+ } else {
 
 
 
 
658
  // update
659
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
660
  if ($has_fifu_attachment) {
676
  $this->delete_attachment_meta_url_and_alt($attachments);
677
  }
678
  }
679
+ if (fifu_is_on('fifu_save_dimensions'))
680
+ fifu_update_or_delete_value($att_id, 'fifu_image_dimension', fifu_get_dimension_backend($url));
681
  }
682
  }
683
 
858
  return $db->save_dimensions_all();
859
  }
860
 
861
+ /* dimensions: clean all */
862
+
863
+ function fifu_db_clean_dimensions_all() {
864
+ $db = new FifuDb();
865
+ return $db->clean_dimensions_all();
866
+ }
867
+
868
  /* clean metadata */
869
 
870
  function fifu_db_enable_clean() {
admin/html/js/menu.js CHANGED
@@ -161,3 +161,29 @@ function fifu_save_dimensions_all_js() {
161
  }
162
  });
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
  });
163
  }
164
+
165
+ function fifu_clean_dimensions_all_js() {
166
+ if (jQuery("#fifu_toggle_clean_dimensions_all").attr('class') != 'toggleon')
167
+ return;
168
+
169
+ jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
170
+
171
+ jQuery.ajax({
172
+ method: "POST",
173
+ url: homeUrl() + '?rest_route=/featured-image-from-url/v2/clean_dimensions_all_api/',
174
+ async: true,
175
+ success: function (data) {
176
+ },
177
+ error: function (jqXHR, textStatus, errorThrown) {
178
+ console.log(jqXHR);
179
+ console.log(textStatus);
180
+ console.log(errorThrown);
181
+ },
182
+ complete: function () {
183
+ setTimeout(function () {
184
+ jQuery("#fifu_toggle_clean_dimensions_all").attr('class', 'toggleoff');
185
+ jQuery('.wrap').unblock();
186
+ }, 1000);
187
+ }
188
+ });
189
+ }
admin/html/menu.html CHANGED
@@ -62,13 +62,15 @@
62
  </td>
63
  </tr>
64
  </table>
65
- <h3>2) "How to get support?"</h3>
66
  You can inform any problem related to the Premium version by email (support@featuredimagefromurl.com). It will be solved as soon as possible and without any cost.<br><br>
67
- <h3>3) "Which plugins are compatible with Premium version?"</h3>
 
 
68
  WooCommerce, WP All Import, Monarch, Frontend Publishing and others. If you intend to use the Premium version with a specific plugin, try to test with this free version first. Or you can ask me if they are compatible.<br><br>
69
- <h3>4) "Are there known incompatibility issues?"</h3>
70
  Some WooCommerce themes aren’t flexible enough to work with Videos, Sliders and Shortcodes. To know if your theme is compatible with those features, please take a look below.<br><br>
71
- <h3>5) "Can I get my money back later?"</h3>
72
  With the exception of rare situations, no. But don't worry about that. You will still have the best support and if, after your complete cooperation, I'm not able to solve your issue, I can refund you.<br><br>
73
  </div>
74
  </div>
@@ -224,6 +226,39 @@
224
  value=""
225
  style="display:block">
226
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  </div>
228
  <div id="tabs-b">
229
  <div class="box">
@@ -976,7 +1011,7 @@
976
  </form>
977
  </th>
978
  <th>
979
- save image dimensions (makes posts updates slower)
980
  </th>
981
  </tr>
982
  <tr>
@@ -1005,7 +1040,34 @@
1005
  <th>
1006
  save the image dimensions of all external featured images now (it shoud take 1-5 seconds by image and requires php-curl installed)
1007
  </th>
1008
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1009
  </table>
1010
 
1011
  </div>
@@ -2600,14 +2662,16 @@
2600
  Version:<?php echo fifu_version() ?>;
2601
  Site:<?php echo get_home_url() ?>;
2602
  Theme:<?php echo wp_get_theme() ?>;
2603
- Plugins:<?php echo fifu_get_plugins_list() ?>;
2604
  PHP:<?php echo phpversion() ?>;
2605
  WooCommerce:<?php echo class_exists('WooCommerce') ? WC()->version : '' ?>;
2606
  WordPress:<?php echo get_bloginfo('version') ?>;
2607
  Pages:<?php echo wp_count_posts('page')->publish ?>;
2608
  Posts:<?php echo wp_count_posts('post')->publish ?>;
2609
  Products:<?php echo class_exists('WooCommerce') ? wp_count_posts('product')->publish : null ?>;
 
 
2610
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
 
2611
  fifu_column_height:<?php echo $column_height ?>;
2612
  fifu_content:<?php echo $enable_content ?>;
2613
  fifu_content_page:<?php echo $enable_content_page ?>;
@@ -2639,6 +2703,7 @@ fifu_image_width_post:<?php echo $max_image_width_post ?>;
2639
  fifu_image_width_prod:<?php echo $max_image_width_prod ?>;
2640
  fifu_image_width_shop:<?php echo $max_image_width_shop ?>;
2641
  fifu_lazy:<?php echo $enable_lazy ?>;
 
2642
  fifu_original:<?php echo $enable_original ?>;
2643
  fifu_ovw_first:<?php echo $enable_ovw_first ?>;
2644
  fifu_pop_first:<?php echo $enable_pop_first ?>;
62
  </td>
63
  </tr>
64
  </table>
65
+ <h3>2) "How to get support?"</h3>
66
  You can inform any problem related to the Premium version by email (support@featuredimagefromurl.com). It will be solved as soon as possible and without any cost.<br><br>
67
+ <h3>3) "On how many sites can I install that?"</h3>
68
+ Only one. Or maybe two, since one of them is a stage site. But both should be available on the Internet to receive automatic updates. Those restrictions are necessary to keep the support quality.<br><br>
69
+ <h3>4) "Which plugins are compatible with Premium version?"</h3>
70
  WooCommerce, WP All Import, Monarch, Frontend Publishing and others. If you intend to use the Premium version with a specific plugin, try to test with this free version first. Or you can ask me if they are compatible.<br><br>
71
+ <h3>5) "Are there known incompatibility issues?"</h3>
72
  Some WooCommerce themes aren’t flexible enough to work with Videos, Sliders and Shortcodes. To know if your theme is compatible with those features, please take a look below.<br><br>
73
+ <h3>6) "Can I get my money back later?"</h3>
74
  With the exception of rare situations, no. But don't worry about that. You will still have the best support and if, after your complete cooperation, I'm not able to solve your issue, I can refund you.<br><br>
75
  </div>
76
  </div>
226
  value=""
227
  style="display:block">
228
  </div>
229
+ <div class="box">
230
+ <h2>Media Library</h2>
231
+ <div class="greybox">
232
+ Enable that to show the external images in your media library.
233
+ </div>
234
+ <br>
235
+ <form
236
+ id="fifu_form_media_library"
237
+ action="javascript:void(0)"
238
+ method="post">
239
+ <table>
240
+ <tr>
241
+ <td>
242
+ <input
243
+ type="image"
244
+ href="javascript:void(0)"
245
+ id="fifu_toggle_media_library"
246
+ onclick="invert('media_library')"
247
+ name="fifu_toggle_media_library"
248
+ class="<?php echo $enable_media_library; ?>"
249
+ value=""
250
+ style="display:block">
251
+
252
+ <input
253
+ type="hidden"
254
+ id="fifu_input_media_library"
255
+ name="fifu_input_media_library"
256
+ value="" ></td>
257
+ <td></td>
258
+ </tr>
259
+ </table>
260
+ </form>
261
+ </div>
262
  </div>
263
  <div id="tabs-b">
264
  <div class="box">
1011
  </form>
1012
  </th>
1013
  <th>
1014
+ save and use image dimensions (makes posts updates slower)
1015
  </th>
1016
  </tr>
1017
  <tr>
1040
  <th>
1041
  save the image dimensions of all external featured images now (it shoud take 1-5 seconds by image and requires php-curl installed)
1042
  </th>
1043
+ </tr>
1044
+ <tr>
1045
+ <th>
1046
+ <form
1047
+ id="fifu_form_clean_dimensions_all"
1048
+ action="javascript:void(0)"
1049
+ method="post">
1050
+ <input
1051
+ type="image"
1052
+ href="javascript:void(0)"
1053
+ id="fifu_toggle_clean_dimensions_all"
1054
+ onclick="invert('clean_dimensions_all');fifu_clean_dimensions_all_js();"
1055
+ name="fifu_toggle_clean_dimensions_all"
1056
+ class="<?php echo $enable_clean_dimensions_all; ?>"
1057
+ value=""
1058
+ style="display:block">
1059
+
1060
+ <input
1061
+ type="hidden"
1062
+ id="fifu_input_clean_dimensions_all"
1063
+ name="fifu_input_clean_dimensions_all"
1064
+ value="" >
1065
+ </form>
1066
+ </th>
1067
+ <th>
1068
+ clean the image dimensions of all external featured images now
1069
+ </th>
1070
+ </tr>
1071
  </table>
1072
 
1073
  </div>
2662
  Version:<?php echo fifu_version() ?>;
2663
  Site:<?php echo get_home_url() ?>;
2664
  Theme:<?php echo wp_get_theme() ?>;
 
2665
  PHP:<?php echo phpversion() ?>;
2666
  WooCommerce:<?php echo class_exists('WooCommerce') ? WC()->version : '' ?>;
2667
  WordPress:<?php echo get_bloginfo('version') ?>;
2668
  Pages:<?php echo wp_count_posts('page')->publish ?>;
2669
  Posts:<?php echo wp_count_posts('post')->publish ?>;
2670
  Products:<?php echo class_exists('WooCommerce') ? wp_count_posts('product')->publish : null ?>;
2671
+ Plugins:<?php echo fifu_get_plugins_list() ?>;
2672
+ Active Plugins:<?php echo fifu_get_active_plugins_list() ?>;
2673
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
2674
+ fifu_clean_dimensions_all:<?php echo $enable_clean_dimensions_all ?>;
2675
  fifu_column_height:<?php echo $column_height ?>;
2676
  fifu_content:<?php echo $enable_content ?>;
2677
  fifu_content_page:<?php echo $enable_content_page ?>;
2703
  fifu_image_width_prod:<?php echo $max_image_width_prod ?>;
2704
  fifu_image_width_shop:<?php echo $max_image_width_shop ?>;
2705
  fifu_lazy:<?php echo $enable_lazy ?>;
2706
+ fifu_media_library:<?php echo $enable_media_library ?>;
2707
  fifu_original:<?php echo $enable_original ?>;
2708
  fifu_ovw_first:<?php echo $enable_ovw_first ?>;
2709
  fifu_pop_first:<?php echo $enable_pop_first ?>;
admin/html/meta-box.html CHANGED
@@ -61,9 +61,9 @@
61
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
62
  background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
63
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
64
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: Integration with <a href="https://wordpress.org/plugins/accelerated-mobile-pages/"><b>Accelerated Mobile Pages</b></a> plugin</p>
65
- <!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
66
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;"><b>New</b> (Premium): supports videos from Facebook, Instagram, Imgur and 9GAG</p-->
67
- <!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
68
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;"><b>New</b>: Compatibility with <a href="https://wclovers.com/knowledgebase/wcfm-custom-fields/"><b>WooCommerce Frontend Manager</b></a> plugin</p-->
69
  </div>
61
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
62
  background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
63
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
64
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: option to show/hide the external images in media library</p>
65
+ <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
66
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: clean image dimensions option</p>
67
+ <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
68
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: integration with WooCommerce TM Extra Product Options</b></a> plugin</p>
69
  </div>
admin/menu.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_original', 'fifu_lazy', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_fake', 'fifu_fake2', 'fifu_css', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_column_height', 'fifu_priority', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_data_generation', 'fifu_data_clean', 'fifu_image_height_shop', 'fifu_image_width_shop', 'fifu_image_height_prod', 'fifu_image_width_prod', 'fifu_image_height_cart', 'fifu_image_width_cart', 'fifu_image_height_ctgr', 'fifu_image_width_ctgr', 'fifu_image_height_arch', 'fifu_image_width_arch', 'fifu_image_height_home', 'fifu_image_width_home', 'fifu_image_height_page', 'fifu_image_width_page', 'fifu_image_height_post', 'fifu_image_width_post', 'fifu_save_dimensions', 'fifu_save_dimensions_all')));
4
 
5
  add_action('admin_menu', 'fifu_insert_menu');
6
 
@@ -28,6 +28,7 @@ function fifu_get_menu_html() {
28
  $enable_social = get_option('fifu_social');
29
  $enable_original = get_option('fifu_original');
30
  $enable_lazy = get_option('fifu_lazy');
 
31
  $enable_content = get_option('fifu_content');
32
  $enable_content_page = get_option('fifu_content_page');
33
  $enable_fake = get_option('fifu_fake');
@@ -65,7 +66,8 @@ function fifu_get_menu_html() {
65
  $max_image_height_post = get_option('fifu_image_height_post');
66
  $max_image_width_post = get_option('fifu_image_width_post');
67
  $enable_save_dimensions = get_option('fifu_save_dimensions');
68
- $enable_save_dimensions_all = get_option('fifu_save_dimensions_all');
 
69
 
70
  include 'html/menu.html';
71
 
@@ -124,6 +126,7 @@ function fifu_update_menu_options() {
124
  fifu_update_option('fifu_input_social', 'fifu_social');
125
  fifu_update_option('fifu_input_original', 'fifu_original');
126
  fifu_update_option('fifu_input_lazy', 'fifu_lazy');
 
127
  fifu_update_option('fifu_input_content', 'fifu_content');
128
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
129
  fifu_update_option('fifu_input_fake', 'fifu_fake');
@@ -162,6 +165,7 @@ function fifu_update_menu_options() {
162
  fifu_update_option('fifu_input_image_width_post', 'fifu_image_width_post');
163
  fifu_update_option('fifu_input_save_dimensions', 'fifu_save_dimensions');
164
  fifu_update_option('fifu_input_save_dimensions_all', 'fifu_save_dimensions_all');
 
165
  }
166
 
167
  function fifu_update_option($input, $type) {
@@ -212,10 +216,18 @@ function fifu_version() {
212
 
213
  function fifu_get_plugins_list() {
214
  $list = '';
215
- $count = 0;
216
  foreach (get_plugins() as $key => $domain) {
217
  $name = $domain['Name'] . ' (' . $domain['TextDomain'] . ')';
218
- $list .= ($count++ == 0) ? $name : ', ' . $name;
 
 
 
 
 
 
 
 
 
219
  }
220
  return $list;
221
  }
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_original', 'fifu_lazy', 'fifu_media_library', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_fake', 'fifu_fake2', 'fifu_css', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_column_height', 'fifu_priority', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_data_generation', 'fifu_data_clean', 'fifu_image_height_shop', 'fifu_image_width_shop', 'fifu_image_height_prod', 'fifu_image_width_prod', 'fifu_image_height_cart', 'fifu_image_width_cart', 'fifu_image_height_ctgr', 'fifu_image_width_ctgr', 'fifu_image_height_arch', 'fifu_image_width_arch', 'fifu_image_height_home', 'fifu_image_width_home', 'fifu_image_height_page', 'fifu_image_width_page', 'fifu_image_height_post', 'fifu_image_width_post', 'fifu_save_dimensions', 'fifu_save_dimensions_all', 'fifu_clean_dimensions_all')));
4
 
5
  add_action('admin_menu', 'fifu_insert_menu');
6
 
28
  $enable_social = get_option('fifu_social');
29
  $enable_original = get_option('fifu_original');
30
  $enable_lazy = get_option('fifu_lazy');
31
+ $enable_media_library = get_option('fifu_media_library');
32
  $enable_content = get_option('fifu_content');
33
  $enable_content_page = get_option('fifu_content_page');
34
  $enable_fake = get_option('fifu_fake');
66
  $max_image_height_post = get_option('fifu_image_height_post');
67
  $max_image_width_post = get_option('fifu_image_width_post');
68
  $enable_save_dimensions = get_option('fifu_save_dimensions');
69
+ $enable_save_dimensions_all = 'toggleoff';
70
+ $enable_clean_dimensions_all = 'toggleoff';
71
 
72
  include 'html/menu.html';
73
 
126
  fifu_update_option('fifu_input_social', 'fifu_social');
127
  fifu_update_option('fifu_input_original', 'fifu_original');
128
  fifu_update_option('fifu_input_lazy', 'fifu_lazy');
129
+ fifu_update_option('fifu_input_media_library', 'fifu_media_library');
130
  fifu_update_option('fifu_input_content', 'fifu_content');
131
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
132
  fifu_update_option('fifu_input_fake', 'fifu_fake');
165
  fifu_update_option('fifu_input_image_width_post', 'fifu_image_width_post');
166
  fifu_update_option('fifu_input_save_dimensions', 'fifu_save_dimensions');
167
  fifu_update_option('fifu_input_save_dimensions_all', 'fifu_save_dimensions_all');
168
+ fifu_update_option('fifu_input_clean_dimensions_all', 'fifu_clean_dimensions_all');
169
  }
170
 
171
  function fifu_update_option($input, $type) {
216
 
217
  function fifu_get_plugins_list() {
218
  $list = '';
 
219
  foreach (get_plugins() as $key => $domain) {
220
  $name = $domain['Name'] . ' (' . $domain['TextDomain'] . ')';
221
+ $list .= '&#10; - ' . $name;
222
+ }
223
+ return $list;
224
+ }
225
+
226
+ function fifu_get_active_plugins_list() {
227
+ $list = '';
228
+ foreach (get_option('active_plugins') as $key) {
229
+ $name = explode('/', $key)[0];
230
+ $list .= '&#10; - ' . $name;
231
  }
232
  return $list;
233
  }
admin/meta-box.php CHANGED
@@ -132,16 +132,6 @@ function fifu_wai_save($post_id) {
132
  fifu_save($post_id);
133
  }
134
 
135
- function fifu_save_dimensions($post_id, $url) {
136
- $size = getimagesize($url);
137
- if ($size) {
138
- $width = $size[0];
139
- $height = $size[1];
140
- if ($width && $height)
141
- fifu_update_or_delete_value($post_id, 'fifu_image_dimension', $width . ';' . $height);
142
- }
143
- }
144
-
145
  add_action('before_delete_post', 'fifu_db_before_delete_post');
146
 
147
  /* regular woocommerce import */
132
  fifu_save($post_id);
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
135
  add_action('before_delete_post', 'fifu_db_before_delete_post');
136
 
137
  /* regular woocommerce import */
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
7
- * Version: 2.5.4
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
7
+ * Version: 2.5.5
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
includes/attachment.php CHANGED
@@ -50,13 +50,21 @@ function fifu_replace_attachment_url($att_url, $att_id) {
50
  add_filter('posts_where', 'fifu_query_attachments');
51
 
52
  function fifu_query_attachments($where) {
53
- if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments')) {
54
  global $wpdb;
55
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> 77777 ';
56
  }
57
  return $where;
58
  }
59
 
 
 
 
 
 
 
 
 
60
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
61
 
62
  function fifu_replace_attachment_image_src($image, $att_id, $size) {
@@ -77,22 +85,12 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
77
  null,
78
  );
79
  }
80
-
81
- $dimension = $post ? get_post_meta($post->post_parent, 'fifu_image_dimension') : null;
82
- if ($dimension && fifu_is_on('fifu_image_dimension')) {
83
- $dimension = $dimension[0];
84
- $width = explode(';', $dimension)[0];
85
- $height = explode(';', $dimension)[1];
86
- } else {
87
- $dimension = null;
88
- $width = fifu_maximum('width');
89
- $height = fifu_maximum('height');
90
- }
91
-
92
  return array(
93
  strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
94
- !$dimension && isset($image_size['width']) && $image_size['width'] < $width ? $image_size['width'] : $width,
95
- !$dimension && isset($image_size['height']) && $image_size['height'] < $height ? $image_size['height'] : $height,
96
  isset($image_size['crop']) ? $image_size['crop'] : '',
97
  );
98
  }
@@ -122,23 +120,29 @@ function fifu_get_internal_image_path() {
122
  return $_SERVER['SERVER_NAME'] . "/wp-content/uploads/";
123
  }
124
 
125
- // yoast warnings and notices
126
-
127
  add_filter('wp_get_attachment_metadata', 'fifu_filter_wp_get_attachment_metadata', 10, 2);
128
 
129
  function fifu_filter_wp_get_attachment_metadata($data, $post_id) {
130
- if (!function_exists('is_plugin_active'))
131
- require_once(ABSPATH . '/wp-admin/includes/plugin.php');
132
-
133
- if (is_plugin_active('wordpress-seo/wp-seo.php') && !$data) {
134
- $arr_size = array();
135
- $arr_size['width'] = null;
136
- $arr_size['height'] = null;
137
- return $arr_size;
138
  }
139
  return $data;
140
  }
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  // accelerated-mobile-pages plugin
143
 
144
  function fifu_amp_url($url, $width, $height) {
50
  add_filter('posts_where', 'fifu_query_attachments');
51
 
52
  function fifu_query_attachments($where) {
53
+ if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments') && fifu_is_off('fifu_media_library')) {
54
  global $wpdb;
55
  $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> 77777 ';
56
  }
57
  return $where;
58
  }
59
 
60
+ add_filter('posts_where', function ( $where, \WP_Query $q ) {
61
+ if (is_admin() && $q->is_main_query() && fifu_is_off('fifu_media_library')) {
62
+ global $wpdb;
63
+ $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> 77777 ';
64
+ }
65
+ return $where;
66
+ }, 10, 2);
67
+
68
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
69
 
70
  function fifu_replace_attachment_image_src($image, $att_id, $size) {
85
  null,
86
  );
87
  }
88
+ $dimension = $post ? get_post_meta($post, 'fifu_image_dimension') : null;
89
+ $arrFIFU = fifu_get_width_height($dimension);
 
 
 
 
 
 
 
 
 
 
90
  return array(
91
  strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
92
+ !$dimension && isset($image_size['width']) && $image_size['width'] < $arrFIFU['width'] ? $image_size['width'] : $arrFIFU['width'],
93
+ !$dimension && isset($image_size['height']) && $image_size['height'] < $arrFIFU['height'] ? $image_size['height'] : $arrFIFU['height'],
94
  isset($image_size['crop']) ? $image_size['crop'] : '',
95
  );
96
  }
120
  return $_SERVER['SERVER_NAME'] . "/wp-content/uploads/";
121
  }
122
 
 
 
123
  add_filter('wp_get_attachment_metadata', 'fifu_filter_wp_get_attachment_metadata', 10, 2);
124
 
125
  function fifu_filter_wp_get_attachment_metadata($data, $post_id) {
126
+ if (!$data || !is_array($data)) {
127
+ $dimension = get_post_meta($post_id, 'fifu_image_dimension');
128
+ return fifu_get_width_height($dimension);
 
 
 
 
 
129
  }
130
  return $data;
131
  }
132
 
133
+ function fifu_get_width_height($dimension) {
134
+ if ($dimension && fifu_is_on('fifu_save_dimensions')) {
135
+ $dimension = $dimension[0];
136
+ $width = explode(';', $dimension)[0];
137
+ $height = explode(';', $dimension)[1];
138
+ } else {
139
+ $dimension = null;
140
+ $width = fifu_maximum('width');
141
+ $height = fifu_maximum('height');
142
+ }
143
+ return array('width' => $width, 'height' => $height);
144
+ }
145
+
146
  // accelerated-mobile-pages plugin
147
 
148
  function fifu_amp_url($url, $width, $height) {
includes/util.php CHANGED
@@ -53,7 +53,7 @@ function fifu_maximum($dimension) {
53
  $size = get_option($dimension . 'arch');
54
  }
55
 
56
- return $size ? $size : '1024';
57
  }
58
 
59
  /* dimensions */
53
  $size = get_option($dimension . 'arch');
54
  }
55
 
56
+ return $size ? $size : null;
57
  }
58
 
59
  /* dimensions */
readme.txt CHANGED
@@ -159,6 +159,9 @@ Features:
159
 
160
  == Changelog ==
161
 
 
 
 
162
  = 2.5.4 =
163
  * Improvement: integration with Accelerated Mobile Pages plugin.
164
 
@@ -591,6 +594,9 @@ was removed. To finish, a Premium version is now been presented.
591
 
592
  == Upgrade Notice ==
593
 
 
 
 
594
  = 2.5.4 =
595
  * Improvement: integration with Accelerated Mobile Pages plugin.
596
 
159
 
160
  == Changelog ==
161
 
162
+ = 2.5.5 =
163
+ * Improvements: option to show/hide external images in media library; option to clean image dimensions.
164
+
165
  = 2.5.4 =
166
  * Improvement: integration with Accelerated Mobile Pages plugin.
167
 
594
 
595
  == Upgrade Notice ==
596
 
597
+ = 2.5.5 =
598
+ * Improvements: option to show/hide external images in media library; option to clean image dimensions.
599
+
600
  = 2.5.4 =
601
  * Improvement: integration with Accelerated Mobile Pages plugin.
602