Featured Image From URL - Version 2.7.6

Version Description

  • New: Getting Started; New FREE Feature: Admin Area > Database; Bug Fix: WooCommerce zoom; Deprecated: Fake Internal Featured Image (1 attachment for all); Improvement: faster menu settings.
Download this release

Release Info

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

Code changes from version 2.7.5 to 2.7.6

admin/api.php CHANGED
@@ -1,15 +1,12 @@
1
  <?php
2
 
3
  function fifu_enable_fake_api(WP_REST_Request $request) {
4
- update_option('fifu_data_generation', 'toggleoff');
5
- update_option('fifu_fake', 'toggleoff');
6
- fifu_disable_fake();
7
-
8
- fifu_enable_fake2();
9
  }
10
 
11
  function fifu_disable_fake_api(WP_REST_Request $request) {
12
- fifu_disable_fake2();
 
13
  }
14
 
15
  function fifu_none_fake_api(WP_REST_Request $request) {
@@ -19,9 +16,6 @@ function fifu_none_fake_api(WP_REST_Request $request) {
19
  function fifu_data_clean_api(WP_REST_Request $request) {
20
  fifu_db_enable_clean();
21
  update_option('fifu_data_clean', 'toggleoff', 'no');
22
-
23
- fifu_disable_fake(); // fake1
24
- update_option('fifu_data_generation', 'toggleoff', 'no');
25
  }
26
 
27
  function fifu_save_dimensions_all_api(WP_REST_Request $request) {
1
  <?php
2
 
3
  function fifu_enable_fake_api(WP_REST_Request $request) {
4
+ fifu_enable_fake();
 
 
 
 
5
  }
6
 
7
  function fifu_disable_fake_api(WP_REST_Request $request) {
8
+ fifu_disable_fake();
9
+ delete_option('fifu_fake_attach_id');
10
  }
11
 
12
  function fifu_none_fake_api(WP_REST_Request $request) {
16
  function fifu_data_clean_api(WP_REST_Request $request) {
17
  fifu_db_enable_clean();
18
  update_option('fifu_data_clean', 'toggleoff', 'no');
 
 
 
19
  }
20
 
21
  function fifu_save_dimensions_all_api(WP_REST_Request $request) {
admin/db.php CHANGED
@@ -21,7 +21,7 @@ class FifuDb {
21
  $this->term_taxonomy = $wpdb->prefix . 'term_taxonomy';
22
  $this->term_relationships = $wpdb->prefix . 'term_relationships';
23
  $this->author = 77777;
24
- $this->MAX_INSERT = 100;
25
  $this->MAX_URL_LENGTH = 2048;
26
  $this->types = $this->get_types();
27
  }
@@ -272,16 +272,6 @@ class FifuDb {
272
  return $result ? $result[0]->ids : null;
273
  }
274
 
275
- function get_posts_with_valid_url() {
276
- return $this->wpdb->get_results("
277
- SELECT post_id
278
- FROM " . $this->postmeta . "
279
- WHERE meta_key = 'fifu_image_url'
280
- AND meta_value IS NOT NULL
281
- AND meta_value <> ''"
282
- );
283
- }
284
-
285
  function get_ctgr_attachments_without_post($term_id) {
286
  $result = $this->wpdb->get_results("
287
  SELECT GROUP_CONCAT(id) AS ids
@@ -722,9 +712,6 @@ class FifuDb {
722
  /* save 1 category */
723
 
724
  function ctgr_update_fake_attach_id($term_id) {
725
- if (fifu_is_on('fifu_data_generation'))
726
- return;
727
-
728
  $att_id = get_term_meta($term_id, 'thumbnail_id');
729
  $att_id = $att_id ? $att_id[0] : null;
730
  $has_fifu_attachment = $att_id ? $this->is_fifu_attachment($att_id) : false;
@@ -828,38 +815,10 @@ class FifuDb {
828
  wp_delete_attachment(get_option('fifu_default_attach_id'));
829
  delete_option('fifu_fake_attach_id');
830
  fifu_disable_fake();
831
- fifu_disable_fake2();
832
  update_option('fifu_fake', 'toggleoff', 'no');
833
- update_option('fifu_fake2', 'toggleoff', 'no');
834
  update_option('fifu_fake_created', false, 'no');
835
  }
836
 
837
- /* fake internal featured image 1 */
838
-
839
- function enable_fake1() {
840
- $old_attach_id = get_option('fifu_fake_attach_id');
841
- $value = $this->get_formatted_value('Featured Image from URL', null, 0);
842
- $this->insert_attachment_by($value);
843
- $att_id = $this->wpdb->insert_id;
844
-
845
- update_post_meta($att_id, '_wp_attached_file', ';');
846
- update_option('fifu_fake_attach_id', $att_id);
847
-
848
- foreach ($this->get_posts_without_meta() as $i)
849
- $this->wpdb->insert($this->postmeta, array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $att_id));
850
-
851
- $this->wpdb->update($this->postmeta, array('meta_value' => $att_id), array('meta_key' => '_thumbnail_id', 'meta_value' => $old_attach_id), null, null);
852
-
853
- foreach ($this->get_posts_with_valid_url() as $i)
854
- $this->wpdb->update($this->postmeta, array('meta_value' => $att_id), array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1), null, null);
855
- }
856
-
857
- function disable_fake1() {
858
- $this->wpdb->delete($this->postmeta, array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_fake_attach_id')));
859
- wp_delete_attachment(get_option('fifu_fake_attach_id'));
860
- delete_option('fifu_fake_attach_id');
861
- }
862
-
863
  }
864
 
865
  /* fake internal featured image */
@@ -987,15 +946,3 @@ function fifu_db_number_of_posts() {
987
  return $db->get_number_of_posts();
988
  }
989
 
990
- /* fake internal featured image 1 */
991
-
992
- function fifu_db_enable_fake1() {
993
- $db = new FifuDb();
994
- return $db->enable_fake1();
995
- }
996
-
997
- function fifu_db_disable_fake1() {
998
- $db = new FifuDb();
999
- return $db->disable_fake1();
1000
- }
1001
-
21
  $this->term_taxonomy = $wpdb->prefix . 'term_taxonomy';
22
  $this->term_relationships = $wpdb->prefix . 'term_relationships';
23
  $this->author = 77777;
24
+ $this->MAX_INSERT = get_option('fifu_spinner_db');
25
  $this->MAX_URL_LENGTH = 2048;
26
  $this->types = $this->get_types();
27
  }
272
  return $result ? $result[0]->ids : null;
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
275
  function get_ctgr_attachments_without_post($term_id) {
276
  $result = $this->wpdb->get_results("
277
  SELECT GROUP_CONCAT(id) AS ids
712
  /* save 1 category */
713
 
714
  function ctgr_update_fake_attach_id($term_id) {
 
 
 
715
  $att_id = get_term_meta($term_id, 'thumbnail_id');
716
  $att_id = $att_id ? $att_id[0] : null;
717
  $has_fifu_attachment = $att_id ? $this->is_fifu_attachment($att_id) : false;
815
  wp_delete_attachment(get_option('fifu_default_attach_id'));
816
  delete_option('fifu_fake_attach_id');
817
  fifu_disable_fake();
 
818
  update_option('fifu_fake', 'toggleoff', 'no');
 
819
  update_option('fifu_fake_created', false, 'no');
820
  }
821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
822
  }
823
 
824
  /* fake internal featured image */
946
  return $db->get_number_of_posts();
947
  }
948
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/html/css/menu.css CHANGED
@@ -99,3 +99,45 @@ th {
99
  background-color: #23282d;
100
  color: white;
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  background-color: #23282d;
100
  color: white;
101
  }
102
+
103
+ .speech-bubble {
104
+ position: relative;
105
+ background: #799d60;
106
+ border-radius: 1em;
107
+ width: 660px;
108
+ }
109
+
110
+ .speech-bubble:after {
111
+ content: '';
112
+ position: absolute;
113
+ right: 0;
114
+ top: 50%;
115
+ width: 0;
116
+ height: 0;
117
+ border: 12px solid transparent;
118
+ border-left-color: #799d60;
119
+ border-right: 0;
120
+ margin-top: -12px;
121
+ margin-right: -12px;
122
+ }
123
+
124
+ .speech-bubble2 {
125
+ position: relative;
126
+ background: #4193aa;
127
+ border-radius: 1em;
128
+ width: 100%;
129
+ }
130
+
131
+ .speech-bubble2:after {
132
+ content: '';
133
+ position: absolute;
134
+ top: 0;
135
+ left: 88%;
136
+ width: 0;
137
+ height: 0;
138
+ border: 12px solid transparent;
139
+ border-bottom-color: #4193aa;
140
+ border-top: 0;
141
+ margin-left: -12px;
142
+ margin-top: -12px;
143
+ }
admin/html/js/menu.js CHANGED
@@ -1,7 +1,6 @@
1
  jQuery(document).ready(function () {
2
  window.scrollTo(0, 0);
3
  jQuery('.wrap').css('opacity', 1);
4
- fifu_fake1_js();
5
  });
6
 
7
  function homeUrl() {
@@ -93,23 +92,10 @@ function fifu_default_js() {
93
  });
94
  }
95
 
96
- function fifu_fake1_js() {
97
- if (jQuery('#fifu_toggle_fake').attr('class') == 'toggleon') {
98
- jQuery('#tr_fake1').show();
99
- jQuery('#tr_fake2').hide();
100
- } else if (jQuery('#fifu_toggle_fake2').attr('class') == 'toggleon') {
101
- jQuery('#tr_fake1').hide();
102
- jQuery('#tr_fake2').show();
103
- } else {
104
- jQuery('#tr_fake1').show();
105
- jQuery('#tr_fake2').show();
106
- }
107
- }
108
-
109
  function fifu_fake_js() {
110
  jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
111
 
112
- toggle = jQuery("#fifu_toggle_fake2").attr('class');
113
  switch (toggle) {
114
  case "toggleon":
115
  option = "enable_fake_api";
@@ -133,7 +119,6 @@ function fifu_fake_js() {
133
  },
134
  complete: function () {
135
  setTimeout(function () {
136
- jQuery("#fifu_toggle_fake").attr('class', 'toggleoff');
137
  jQuery('.wrap').unblock();
138
  }, 1000);
139
  },
@@ -162,7 +147,6 @@ function fifu_clean_js() {
162
  setTimeout(function () {
163
  jQuery("#fifu_toggle_data_clean").attr('class', 'toggleoff');
164
  jQuery("#fifu_toggle_fake").attr('class', 'toggleoff');
165
- jQuery("#fifu_toggle_fake2").attr('class', 'toggleoff');
166
  jQuery('.wrap').unblock();
167
  }, 1000);
168
  }
1
  jQuery(document).ready(function () {
2
  window.scrollTo(0, 0);
3
  jQuery('.wrap').css('opacity', 1);
 
4
  });
5
 
6
  function homeUrl() {
92
  });
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  function fifu_fake_js() {
96
  jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
97
 
98
+ toggle = jQuery("#fifu_toggle_fake").attr('class');
99
  switch (toggle) {
100
  case "toggleon":
101
  option = "enable_fake_api";
119
  },
120
  complete: function () {
121
  setTimeout(function () {
 
122
  jQuery('.wrap').unblock();
123
  }, 1000);
124
  },
147
  setTimeout(function () {
148
  jQuery("#fifu_toggle_data_clean").attr('class', 'toggleoff');
149
  jQuery("#fifu_toggle_fake").attr('class', 'toggleoff');
 
150
  jQuery('.wrap').unblock();
151
  }, 1000);
152
  }
admin/html/menu.html CHANGED
@@ -8,8 +8,8 @@
8
  <ul>
9
  <li><a href="#tabs-d"><i class="fas fa-envelope"></i> Help</a></li>
10
  <li><a href="#tabs-k"><i class="fas fa-user-cog"></i> Admin Area</a></li>
11
- <li><a href="#tabs-b"><i class="fas fa-flag-checkered"></i> Auto Set First Image/Video</a></li>
12
  <li><a href="#tabs-g"><i class="fas fa-image"></i> Featured Image</a></li>
 
13
  <li><a href="#tabs-j"><i class="fas fa-database"></i> Metadata</a></li>
14
  <li><a href="#tabs-i"><i class="fas fa-tachometer-alt"></i> Performance</a></li>
15
  <li><a href="#tabs-q"><i class="fas fa-robot"></i> REST API</a></li>
@@ -174,25 +174,32 @@
174
  </div>
175
  <div class="box">
176
  <h2>Database</h2>
177
- <div class="greybox" id="grad2">
178
- <b>Premium feature</b><br><br>
179
- Limit of rows to UPDATE, INSERT or DELETE by query. Higher this number, faster the features Auto Set (Apply to All) and Metadata (Fake Internal Featured Image and Clean). However, if you have limited resources, don't increase this value too much, otherwise your database can bring down.<br><br>
180
- <table style="text-align:left">
181
- <tr>
182
- <th>
183
- <label for="fifu_input_spinner_db"
184
- placehold>Rows Limit</label>
185
- </th>
186
- <th>
187
- <input id="fifu_input_spinner_db"
188
- name="fifu_input_spinner_db"
189
- size="4">
190
- </th>
191
- </tr>
192
- </table>
 
 
 
 
 
 
 
 
 
193
  </div>
194
- <br>
195
- <input type="submit" value="Submit" disabled>
196
  </div>
197
  <div class="box">
198
  <h2>Schedule Metadata Generation</h2>
@@ -295,7 +302,8 @@
295
 
296
  <h2>Configuration</h2>
297
  <div class="greybox">
298
- Perfect for external posts, this option allows to use the first image/video from a post/page/product content as featured image. It will happen when you click on Publish/Update button. For videos, however, you will need the premium version.
 
299
  </div>
300
 
301
  <br>
@@ -417,7 +425,7 @@
417
  It can take some minutes and can't be undone, so make a backup.
418
  To repeat the process enable the toggle again.
419
  <br><br>
420
- To schedule this process (hourly, daily etc), you can use the Hook <b>fifu_event</b> with your favorite cron event plugin. I like <a href="https://wordpress.org/plugins/wp-crontrol/">WP Control</a>.
421
  </div>
422
  <br>
423
  <table style="text-align:left">
@@ -814,7 +822,7 @@
814
  <h2>Validate Images</h2>
815
  <div class="greybox" id="grad2">
816
  <b>Premium feature</b><br><br>
817
- Allows to check image URLs and, when an image is not found, its URL is not saved. However, the validation can make the saving time too long. It is not integrated with Auto Set Featured Image or Rest API features yet.
818
  </div>
819
  <br>
820
  <input
@@ -1197,85 +1205,31 @@
1197
  </div>
1198
  <div id="tabs-j">
1199
  <div class="box">
1200
- <h2>Fake Internal Featured Image</h2>
1201
  <div class="greybox">
1202
- Even though FIFU works fine with the most of themes/plugins, some of them are not able to show the external featured image if there is no internal featured image associated to your post/page/product. Enabling the toggle below, a symbolic empty file will be added to your Media Library as an attempt to overcome that limitation.
1203
  </div>
1204
- <p/>
1205
- <table>
1206
- <tr>
1207
- <td style="width:50px"></td>
1208
- <td style="width:200px">action</td>
1209
- <td style="width:350px">pros</td>
1210
- <td style="width:300px">cons</td>
1211
- </tr>
1212
- <tr id='tr_fake1'>
1213
- <form
1214
- id="fifu_form_fake"
1215
- action="javascript:void(0)"
1216
- method="post">
1217
- <td>
1218
- <input
1219
- type="submit"
1220
- href="javascript:void(0)"
1221
- id="fifu_toggle_fake"
1222
- onclick="invert('fake');
1223
- fifu_fake1_js();"
1224
- name="fifu_toggle_fake"
1225
- class="<?php echo $enable_fake; ?>"
1226
- value=""
1227
- style="display:block;border:none" >
1228
- <input
1229
- type="hidden"
1230
- id="fifu_input_fake"
1231
- name="fifu_input_fake"
1232
- value="" >
1233
- </td>
1234
- <td>
1235
- create one fake image for all URLs (<b>deprecated soon</b>)
1236
- </td>
1237
- <td>
1238
- you can keep your real internal featured image.
1239
- </td>
1240
- <td>
1241
- the site may have some problems to show the external images in some areas or in determined sizes.
1242
- </td>
1243
- </form>
1244
- </tr>
1245
- <tr id='tr_fake2'>
1246
- <form
1247
- id="fifu_form_fake2"
1248
- action="javascript:void(0)"
1249
- method="post">
1250
- <td>
1251
- <input
1252
- type="submit"
1253
- href="javascript:void(0)"
1254
- id="fifu_toggle_fake2"
1255
- onclick="invert('fake2');
1256
- fifu_fake_js();
1257
- fifu_fake1_js()";
1258
- name="fifu_toggle_fake2"
1259
- class="<?php echo $enable_fake2; ?>"
1260
- value=""
1261
- style="display:block;border:none">
1262
- <input
1263
- type="hidden"
1264
- id="fifu_input_fake2"
1265
- name="fifu_input_fake2"
1266
- value="" >
1267
- </td>
1268
- <td>
1269
- create a different fake image for each URL (<b>recommended</b>)
1270
- </td>
1271
- <td>
1272
- the site can show the images anywhere and in the correct size in most cases. Greater chance of the external images being supported by other plugins.
1273
- </td>
1274
- <td>
1275
- the image metadata will replace your real internal featured image if that exists.
1276
- </td>
1277
- </form>
1278
- </tr></table>
1279
  </div>
1280
 
1281
  <div class="box">
@@ -1300,9 +1254,7 @@
1300
  href="javascript:void(0)"
1301
  id="fifu_toggle_data_clean"
1302
  onclick="invert('data_clean');
1303
- fifu_clean_js();
1304
- jQuery('#tr_fake1').show();
1305
- jQuery('#tr_fake2').show();";
1306
  name="fifu_toggle_data_clean"
1307
  class="<?php echo $enable_data_clean; ?>"
1308
  value=""
@@ -1325,7 +1277,9 @@
1325
  <div class="greybox" id="grad2">
1326
  <b>Premium feature</b><br><br>
1327
 
1328
- This experimental feature allows to use a shortcode as "featured image" of posts/pages/products. Using shortcodes you are not limited to images/videos/sliders anymore. You can use any content provided by the shortcode, what could be a music, a text, a whole site etc. However, some contents will need a large area of your site to be shown properly. So you should define a minimum width that an area of your site should have to be able to show the shortcode content, otherwise it will be shown the regular featured image (required field). Important: shortcodes can be not compatible with other FIFU features, such as CSS Style, Crop Image, Lazy Load etc.
 
 
1329
 
1330
  </div>
1331
 
@@ -2659,6 +2613,40 @@
2659
  If you need any help, you can refer to <a href="https://wordpress.org/plugins/featured-image-from-url/screenshots/" target="_blank">screenshots</a> or send an email to <b>marcel@featuredimagefromurl.com</b> (send me this <a href="admin.php?page=fifu-support-data"><button id="opener" onclick="jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});">data</button></a>, please).
2660
  </div>
2661
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2662
  </div>
2663
  <div id="tabs-t">
2664
  <div class="box">
@@ -2768,7 +2756,7 @@
2768
  Replacing http URLs by https:<br>
2769
  1) run this SQL command: UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://', 'https://') WHERE meta_key = 'fifu_image_url' AND meta_value LIKE '%site.com%';<br>
2770
  2) enable "FIFU settings > Metadata > Clean metadata" toggle (it will be automatically disabled after a few minutes);<br>
2771
- 3) enable "Fake Internal Featured Image" (the 2nd toggle).<br>
2772
  * replace site.com by the domain of the URLs you want to update
2773
  </div>
2774
  </div>
@@ -2816,7 +2804,7 @@
2816
  1) deactivate Nelio;<br>
2817
  2) run this SQL command: INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT * FROM (SELECT post_id, 'fifu_image_url' AS meta_key, SUBSTRING_INDEX(SUBSTRING_INDEX(meta_value, '"', 2), '"', -1) AS meta_value FROM wp_postmeta WHERE meta_key = '_nelioefi_first_image') pm WHERE meta_value <> '';<br>
2818
  3) enable "FIFU settings > Metadata > Clean metadata" toggle (it will be automatically disabled after a few minutes);<br>
2819
- 4) enable "Fake Internal Featured Image" (the 2nd toggle only).<br>
2820
  </div>
2821
  </div>
2822
  <div class="box">
8
  <ul>
9
  <li><a href="#tabs-d"><i class="fas fa-envelope"></i> Help</a></li>
10
  <li><a href="#tabs-k"><i class="fas fa-user-cog"></i> Admin Area</a></li>
 
11
  <li><a href="#tabs-g"><i class="fas fa-image"></i> Featured Image</a></li>
12
+ <li><a href="#tabs-b"><i class="fas fa-flag-checkered"></i> URL from Post Content</a></li>
13
  <li><a href="#tabs-j"><i class="fas fa-database"></i> Metadata</a></li>
14
  <li><a href="#tabs-i"><i class="fas fa-tachometer-alt"></i> Performance</a></li>
15
  <li><a href="#tabs-q"><i class="fas fa-robot"></i> REST API</a></li>
174
  </div>
175
  <div class="box">
176
  <h2>Database</h2>
177
+ <div class="greybox">
178
+ Limit of rows to UPDATE, INSERT or DELETE by query. Higher this number, faster the features "URL from Post Content" (Apply to All) and "Metadata" (Fake Internal Featured Image and Clean). However, if you have limited resources, don't increase this value too much, otherwise your database can bring down.<br><br>
179
+ <form
180
+ id="fifu_form_db"
181
+ action="javascript:void(0)"
182
+ method="post">
183
+
184
+ <table style="text-align:left">
185
+ <tr>
186
+ <th>
187
+ <label for="fifu_input_spinner_db"
188
+ placehold>Rows Limit</label>
189
+ </th>
190
+ <th>
191
+ <input id="fifu_input_spinner_db"
192
+ name="fifu_input_spinner_db"
193
+ value="<?php echo $max_db; ?>"
194
+ size="4">
195
+ </th>
196
+ <th>
197
+ <input type="submit" value="Submit">
198
+ </th>
199
+ </tr>
200
+ </table>
201
+ </form>
202
  </div>
 
 
203
  </div>
204
  <div class="box">
205
  <h2>Schedule Metadata Generation</h2>
302
 
303
  <h2>Configuration</h2>
304
  <div class="greybox">
305
+ This option makes FIFU read the HTML of your internal post/page/product content and use the first image/video URL found as "featured image". It will happen when you click on Publish/Update button.<br/><br/>
306
+ <b>Important</b>: the images need to be in an "img" HTML tag and videos (Premium feature) in an "iframe" tag. So contents provided by [shortcodes] can't be read.
307
  </div>
308
 
309
  <br>
425
  It can take some minutes and can't be undone, so make a backup.
426
  To repeat the process enable the toggle again.
427
  <br><br>
428
+ To schedule this process (hourly, daily etc), you can use the Hook <b>fifu_event</b> with your favorite cron event plugin. I like <a href="https://wordpress.org/plugins/wp-crontrol/">this</a> one.
429
  </div>
430
  <br>
431
  <table style="text-align:left">
822
  <h2>Validate Images</h2>
823
  <div class="greybox" id="grad2">
824
  <b>Premium feature</b><br><br>
825
+ Allows to check image URLs and, when an image is not found, its URL is not saved. However, the validation can make the saving time too long. It is not integrated with "URL from Post Content" or "Rest API" features yet.
826
  </div>
827
  <br>
828
  <input
1205
  </div>
1206
  <div id="tabs-j">
1207
  <div class="box">
1208
+ <h2>Fake Internal Featured Image (<b style="color:red">keep me enabled</b>)</h2>
1209
  <div class="greybox">
1210
+ Most themes/plugins are not able to show the external featured image if there is no internal featured image associated to your post/page/product. Enabling the toggle below, a symbolic <b>empty</b> file will be added to your Media Library to overcome this limitation.
1211
  </div>
1212
+ <br>
1213
+ <form
1214
+ id="fifu_form_fake"
1215
+ action="javascript:void(0)"
1216
+ method="post">
1217
+ <input
1218
+ type="submit"
1219
+ href="javascript:void(0)"
1220
+ id="fifu_toggle_fake"
1221
+ onclick="invert('fake');
1222
+ fifu_fake_js();";
1223
+ name="fifu_toggle_fake"
1224
+ class="<?php echo $enable_fake; ?>"
1225
+ value=""
1226
+ style="display:block;border:none">
1227
+ <input
1228
+ type="hidden"
1229
+ id="fifu_input_fake"
1230
+ name="fifu_input_fake"
1231
+ value="" >
1232
+ </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1233
  </div>
1234
 
1235
  <div class="box">
1254
  href="javascript:void(0)"
1255
  id="fifu_toggle_data_clean"
1256
  onclick="invert('data_clean');
1257
+ fifu_clean_js();";
 
 
1258
  name="fifu_toggle_data_clean"
1259
  class="<?php echo $enable_data_clean; ?>"
1260
  value=""
1277
  <div class="greybox" id="grad2">
1278
  <b>Premium feature</b><br><br>
1279
 
1280
+ This experimental feature allows to use a shortcode as "featured image" of posts/pages/products. Using shortcodes you are not limited to images/videos/sliders anymore. You can use any content provided by the shortcode, what could be a music, a text, a whole site etc.<br/><br/>
1281
+ However, some contents will need a large area of your site to be shown properly. So you should define a minimum width that an area of your site should have to be able to show the shortocde content, otherwise it will be shown featured image from url (<b>required field</b>).<br/><br/>
1282
+ Important: shortcodes can be not compatible with other FIFU features, such as CSS Style, Crop Image, Lazy Load etc.
1283
 
1284
  </div>
1285
 
2613
  If you need any help, you can refer to <a href="https://wordpress.org/plugins/featured-image-from-url/screenshots/" target="_blank">screenshots</a> or send an email to <b>marcel@featuredimagefromurl.com</b> (send me this <a href="admin.php?page=fifu-support-data"><button id="opener" onclick="jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});">data</button></a>, please).
2614
  </div>
2615
  </div>
2616
+ <div class="box">
2617
+ <h2>Getting Started (external Featured Images)</h2>
2618
+ <div class="greybox" style="height:480px">
2619
+ <hgroup style="float:left;opacity:0.75;" class="speech-bubble">
2620
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px;padding-top:10px;">Hi, I'm an EXTERNAL image!</div>
2621
+ <br>
2622
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px">It means I'm NOT in your media library and I'm NOT an attached plugin file too.</div>
2623
+ <br>
2624
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px">Don't you believe me? So why don't you check my Internet address (also known as URL)?</div>
2625
+ <br>
2626
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">1) <b>right click</b> me now;</div>
2627
+ <br>
2628
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">2) select "<b>Copy image address</b>";</div>
2629
+ <br>
2630
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">3) <b>paste</b> it here: <input type="text" style="width:480px;background-color:#f3f3f3;font-style:italic;" placeholder="or just drag and drop me here"></div>
2631
+ <br>
2632
+ </hgroup>
2633
+ <img style="float:right;padding-left:30px;padding-bottom:60px;width:200px;position:relative;top:25px;filter:grayscale(25%);" src="https://ps.w.org/featured-image-from-url/assets/icon-256x256.png" title="Right click me!">
2634
+ <hgroup style="float:right;opacity:0.75;" class="speech-bubble2">
2635
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px;padding-top:10px;">Since now you have my address (also known as URL), how about making me famous?</div>
2636
+ <br>
2637
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px">You just need to create a post and use me as the Featured Image:</div>
2638
+ <br>
2639
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">1) <b>add a new post</b>;</div>
2640
+ <br>
2641
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">2) find the "<b>Featured Image from URL</b>" box;</div>
2642
+ <br>
2643
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:40px">3) <b>paste</b> my address into "<b>Image URL</b>" field.</div>
2644
+ <br>
2645
+ <div style="font-style:italic;font-size:14px;color:white;padding-left:25px">And don't worry about storage. I will remain EXTERNAL. I WON'T be uploaded to your media library.</div>
2646
+ <br>
2647
+ </hgroup>
2648
+ </div>
2649
+ </div>
2650
  </div>
2651
  <div id="tabs-t">
2652
  <div class="box">
2756
  Replacing http URLs by https:<br>
2757
  1) run this SQL command: UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://', 'https://') WHERE meta_key = 'fifu_image_url' AND meta_value LIKE '%site.com%';<br>
2758
  2) enable "FIFU settings > Metadata > Clean metadata" toggle (it will be automatically disabled after a few minutes);<br>
2759
+ 3) enable "Fake Internal Featured Image".<br>
2760
  * replace site.com by the domain of the URLs you want to update
2761
  </div>
2762
  </div>
2804
  1) deactivate Nelio;<br>
2805
  2) run this SQL command: INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT * FROM (SELECT post_id, 'fifu_image_url' AS meta_key, SUBSTRING_INDEX(SUBSTRING_INDEX(meta_value, '"', 2), '"', -1) AS meta_value FROM wp_postmeta WHERE meta_key = '_nelioefi_first_image') pm WHERE meta_value <> '';<br>
2806
  3) enable "FIFU settings > Metadata > Clean metadata" toggle (it will be automatically disabled after a few minutes);<br>
2807
+ 4) enable "Fake Internal Featured Image".<br>
2808
  </div>
2809
  </div>
2810
  <div class="box">
admin/html/meta-box.html CHANGED
@@ -5,7 +5,7 @@
5
 
6
  <div style="<?php echo $show_ignore ?>">
7
  <input type="checkbox" name="fifu_ignore_auto_set" id="fifu_ignore_auto_set">
8
- <label for="fifu_ignore_auto_set">ignore Auto Set First Image</label>
9
  <br>
10
  </div>
11
 
5
 
6
  <div style="<?php echo $show_ignore ?>">
7
  <input type="checkbox" name="fifu_ignore_auto_set" id="fifu_ignore_auto_set">
8
+ <label for="fifu_ignore_auto_set">ignore URL from Post Content</label>
9
  <br>
10
  </div>
11
 
admin/html/support-data.html CHANGED
@@ -33,7 +33,6 @@ fifu_default_url:<?php echo $default_url ?>;
33
  fifu_dynamic_alt:<?php echo $enable_dynamic_alt ?>;
34
  fifu_enable_default_url:<?php echo $enable_default_url ?>;
35
  fifu_fake:<?php echo $enable_fake ?>;
36
- fifu_fake2:<?php echo $enable_fake2 ?>;
37
  fifu_get_first:<?php echo $enable_get_first ?>;
38
  fifu_grid_category:<?php echo $enable_grid_category ?>;
39
  fifu_hide_page:<?php echo $enable_hide_page ?>;
@@ -65,6 +64,7 @@ fifu_save_dimensions:<?php echo $enable_save_dimensions ?>;
65
  fifu_save_dimensions_all:<?php echo $enable_save_dimensions_all ?>;
66
  fifu_save_dimensions_redirect:<?php echo $enable_save_dimensions_redirect ?>;
67
  fifu_social:<?php echo $enable_social ?>;
 
68
  fifu_wc_lbox:<?php echo $enable_wc_lbox ?>;
69
  fifu_wc_zoom:<?php echo $enable_wc_zoom ?>;
70
  </textarea>
33
  fifu_dynamic_alt:<?php echo $enable_dynamic_alt ?>;
34
  fifu_enable_default_url:<?php echo $enable_default_url ?>;
35
  fifu_fake:<?php echo $enable_fake ?>;
 
36
  fifu_get_first:<?php echo $enable_get_first ?>;
37
  fifu_grid_category:<?php echo $enable_grid_category ?>;
38
  fifu_hide_page:<?php echo $enable_hide_page ?>;
64
  fifu_save_dimensions_all:<?php echo $enable_save_dimensions_all ?>;
65
  fifu_save_dimensions_redirect:<?php echo $enable_save_dimensions_redirect ?>;
66
  fifu_social:<?php echo $enable_social ?>;
67
+ fifu_spinner_db:<?php echo $max_db ?>;
68
  fifu_wc_lbox:<?php echo $enable_wc_lbox ?>;
69
  fifu_wc_zoom:<?php echo $enable_wc_zoom ?>;
70
  </textarea>
admin/menu.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_original', 'fifu_lazy', 'fifu_jquery', '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_class', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_column_height', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_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_redirect', 'fifu_save_dimensions_all', 'fifu_clean_dimensions_all')));
4
 
5
  add_action('admin_menu', 'fifu_insert_menu');
6
 
@@ -32,10 +32,10 @@ function fifu_support_data() {
32
  $enable_content = get_option('fifu_content');
33
  $enable_content_page = get_option('fifu_content_page');
34
  $enable_fake = get_option('fifu_fake');
35
- $enable_fake2 = get_option('fifu_fake2');
36
  $css_style = get_option('fifu_css');
37
  $default_url = get_option('fifu_default_url');
38
  $enable_default_url = get_option('fifu_enable_default_url');
 
39
  $enable_wc_lbox = get_option('fifu_wc_lbox');
40
  $enable_wc_zoom = get_option('fifu_wc_zoom');
41
  $enable_hide_page = get_option('fifu_hide_page');
@@ -89,10 +89,10 @@ function fifu_get_menu_html() {
89
  $enable_content = get_option('fifu_content');
90
  $enable_content_page = get_option('fifu_content_page');
91
  $enable_fake = get_option('fifu_fake');
92
- $enable_fake2 = get_option('fifu_fake2');
93
  $css_style = get_option('fifu_css');
94
  $default_url = get_option('fifu_default_url');
95
  $enable_default_url = get_option('fifu_enable_default_url');
 
96
  $enable_wc_lbox = get_option('fifu_wc_lbox');
97
  $enable_wc_zoom = get_option('fifu_wc_zoom');
98
  $enable_hide_page = get_option('fifu_hide_page');
@@ -132,15 +132,8 @@ function fifu_get_menu_html() {
132
 
133
  fifu_update_menu_options();
134
 
135
- // fake 1
136
- if (fifu_is_on('fifu_fake')) {
137
- update_option('fifu_data_generation', 'toggleon');
138
- fifu_enable_fake();
139
- } else
140
- fifu_disable_fake();
141
-
142
  // default
143
- if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake2')) {
144
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
145
  $att_id = fifu_db_create_attachment($default_url);
146
  update_option('fifu_default_attach_id', $att_id);
@@ -161,7 +154,9 @@ function fifu_get_setting($type) {
161
  $arrEmpty = array('fifu_default_url', 'fifu_css');
162
  $arrEmptyNo = array('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');
163
  $arr64 = array('fifu_column_height');
164
- $arrOn = array('fifu_fake2', 'fifu_auto_alt', 'fifu_wc_zoom', 'fifu_wc_lbox');
 
 
165
  $arrOffNo = array('fifu_data_clean');
166
 
167
  if (!get_option($type)) {
@@ -171,8 +166,12 @@ function fifu_get_setting($type) {
171
  update_option($type, '', 'no');
172
  else if (in_array($type, $arr64))
173
  update_option($type, "64", 'no');
 
 
174
  else if (in_array($type, $arrOn))
175
  update_option($type, 'toggleon');
 
 
176
  else if (in_array($type, $arrOffNo))
177
  update_option($type, 'toggleoff', 'no');
178
  else
@@ -189,10 +188,10 @@ function fifu_update_menu_options() {
189
  fifu_update_option('fifu_input_content', 'fifu_content');
190
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
191
  fifu_update_option('fifu_input_fake', 'fifu_fake');
192
- fifu_update_option('fifu_input_fake2', 'fifu_fake2');
193
  fifu_update_option('fifu_input_css', 'fifu_css');
194
  fifu_update_option('fifu_input_default_url', 'fifu_default_url');
195
  fifu_update_option('fifu_input_enable_default_url', 'fifu_enable_default_url');
 
196
  fifu_update_option('fifu_input_wc_lbox', 'fifu_wc_lbox');
197
  fifu_update_option('fifu_input_wc_zoom', 'fifu_wc_zoom');
198
  fifu_update_option('fifu_input_hide_page', 'fifu_hide_page');
@@ -240,7 +239,7 @@ function fifu_update_option($input, $type) {
240
  }
241
  }
242
 
243
- function fifu_enable_fake2() {
244
  if (get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
245
  return;
246
  update_option('fifu_fake_created', true, 'no');
@@ -249,9 +248,7 @@ function fifu_enable_fake2() {
249
  fifu_db_insert_attachment_category();
250
  }
251
 
252
- function fifu_disable_fake2() {
253
- if (fifu_is_on('fifu_fake'))
254
- return;
255
  if (!get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
256
  return;
257
  update_option('fifu_fake_created', false, 'no');
@@ -261,16 +258,6 @@ function fifu_disable_fake2() {
261
  fifu_db_delete_attachment_category();
262
  }
263
 
264
- function fifu_enable_fake() {
265
- if (get_option('fifu_fake_attach_id'))
266
- return;
267
- fifu_db_enable_fake1();
268
- }
269
-
270
- function fifu_disable_fake() {
271
- fifu_db_disable_fake1();
272
- }
273
-
274
  function fifu_version() {
275
  $plugin_data = get_plugin_data(FIFU_PLUGIN_DIR . 'featured-image-from-url.php');
276
  return $plugin_data ? $plugin_data['Name'] . ':' . $plugin_data['Version'] : '';
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_original', 'fifu_lazy', 'fifu_jquery', 'fifu_media_library', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_fake', 'fifu_css', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_class', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_column_height', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', '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_redirect', 'fifu_save_dimensions_all', 'fifu_clean_dimensions_all')));
4
 
5
  add_action('admin_menu', 'fifu_insert_menu');
6
 
32
  $enable_content = get_option('fifu_content');
33
  $enable_content_page = get_option('fifu_content_page');
34
  $enable_fake = get_option('fifu_fake');
 
35
  $css_style = get_option('fifu_css');
36
  $default_url = get_option('fifu_default_url');
37
  $enable_default_url = get_option('fifu_enable_default_url');
38
+ $max_db = get_option('fifu_spinner_db');
39
  $enable_wc_lbox = get_option('fifu_wc_lbox');
40
  $enable_wc_zoom = get_option('fifu_wc_zoom');
41
  $enable_hide_page = get_option('fifu_hide_page');
89
  $enable_content = get_option('fifu_content');
90
  $enable_content_page = get_option('fifu_content_page');
91
  $enable_fake = get_option('fifu_fake');
 
92
  $css_style = get_option('fifu_css');
93
  $default_url = get_option('fifu_default_url');
94
  $enable_default_url = get_option('fifu_enable_default_url');
95
+ $max_db = get_option('fifu_spinner_db');
96
  $enable_wc_lbox = get_option('fifu_wc_lbox');
97
  $enable_wc_zoom = get_option('fifu_wc_zoom');
98
  $enable_hide_page = get_option('fifu_hide_page');
132
 
133
  fifu_update_menu_options();
134
 
 
 
 
 
 
 
 
135
  // default
136
+ if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake')) {
137
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
138
  $att_id = fifu_db_create_attachment($default_url);
139
  update_option('fifu_default_attach_id', $att_id);
154
  $arrEmpty = array('fifu_default_url', 'fifu_css');
155
  $arrEmptyNo = array('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');
156
  $arr64 = array('fifu_column_height');
157
+ $arr100 = array('fifu_spinner_db');
158
+ $arrOn = array('fifu_auto_alt', 'fifu_wc_zoom', 'fifu_wc_lbox');
159
+ $arrOnNo = array('fifu_fake');
160
  $arrOffNo = array('fifu_data_clean');
161
 
162
  if (!get_option($type)) {
166
  update_option($type, '', 'no');
167
  else if (in_array($type, $arr64))
168
  update_option($type, "64", 'no');
169
+ else if (in_array($type, $arr100))
170
+ update_option($type, 100, 'no');
171
  else if (in_array($type, $arrOn))
172
  update_option($type, 'toggleon');
173
+ else if (in_array($type, $arrOnNo))
174
+ update_option($type, 'toggleon', 'no');
175
  else if (in_array($type, $arrOffNo))
176
  update_option($type, 'toggleoff', 'no');
177
  else
188
  fifu_update_option('fifu_input_content', 'fifu_content');
189
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
190
  fifu_update_option('fifu_input_fake', 'fifu_fake');
 
191
  fifu_update_option('fifu_input_css', 'fifu_css');
192
  fifu_update_option('fifu_input_default_url', 'fifu_default_url');
193
  fifu_update_option('fifu_input_enable_default_url', 'fifu_enable_default_url');
194
+ fifu_update_option('fifu_input_spinner_db', 'fifu_spinner_db');
195
  fifu_update_option('fifu_input_wc_lbox', 'fifu_wc_lbox');
196
  fifu_update_option('fifu_input_wc_zoom', 'fifu_wc_zoom');
197
  fifu_update_option('fifu_input_hide_page', 'fifu_hide_page');
239
  }
240
  }
241
 
242
+ function fifu_enable_fake() {
243
  if (get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
244
  return;
245
  update_option('fifu_fake_created', true, 'no');
248
  fifu_db_insert_attachment_category();
249
  }
250
 
251
+ function fifu_disable_fake() {
 
 
252
  if (!get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
253
  return;
254
  update_option('fifu_fake_created', false, 'no');
258
  fifu_db_delete_attachment_category();
259
  }
260
 
 
 
 
 
 
 
 
 
 
 
261
  function fifu_version() {
262
  $plugin_data = get_plugin_data(FIFU_PLUGIN_DIR . 'featured-image-from-url.php');
263
  return $plugin_data ? $plugin_data['Name'] . ':' . $plugin_data['Version'] : '';
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.7.5
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
@@ -36,10 +36,20 @@ function fifu_activate($network_wide) {
36
  global $wpdb;
37
  foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
38
  switch_to_blog($blog_id);
39
- fifu_db_change_url_length();
40
  }
41
- } else
42
- fifu_db_change_url_length();
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
@@ -49,7 +59,7 @@ function fifu_upgrade($upgrader_object, $options) {
49
  if ($options['action'] == 'update' && $options['type'] == 'plugin') {
50
  foreach ($options['plugins'] as $each_plugin) {
51
  if ($each_plugin == $current_plugin_path_name)
52
- fifu_db_change_url_length();
53
  }
54
  }
55
  }
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.7.6
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
36
  global $wpdb;
37
  foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
38
  switch_to_blog($blog_id);
39
+ fifu_activate_actions();
40
  }
41
+ } else {
42
+ fifu_activate_actions();
43
+ }
44
+ }
45
+
46
+ function fifu_activate_actions() {
47
+ fifu_db_change_url_length();
48
+
49
+ if (fifu_is_on('fifu_fake2')) {
50
+ update_option('fifu_fake', 'toggleon');
51
+ delete_option('fifu_fake2');
52
+ }
53
  }
54
 
55
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
59
  if ($options['action'] == 'update' && $options['type'] == 'plugin') {
60
  foreach ($options['plugins'] as $each_plugin) {
61
  if ($each_plugin == $current_plugin_path_name)
62
+ fifu_activate_actions();
63
  }
64
  }
65
  }
includes/attachment.php CHANGED
@@ -5,12 +5,10 @@ define("FIFU_URL", "/localhost/fifu/");
5
  add_filter('get_attached_file', 'fifu_replace_attached_file', 10, 2);
6
 
7
  function fifu_replace_attached_file($att_url, $att_id) {
8
- if (fifu_is_off('fifu_data_generation')) {
9
- if ($att_url) {
10
- $url = explode(";", $att_url);
11
- if (sizeof($url) > 1)
12
- return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
13
- }
14
  }
15
  return $att_url;
16
  }
@@ -18,29 +16,18 @@ function fifu_replace_attached_file($att_url, $att_id) {
18
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
19
 
20
  function fifu_replace_attachment_url($att_url, $att_id) {
21
- if (fifu_is_off('fifu_data_generation')) {
22
- if ($att_url) {
23
- $url = explode(";", $att_url);
24
- if (sizeof($url) > 1)
25
- return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
26
- else {
27
- if (get_post($att_id)) {
28
- $url = get_post($att_id)->guid;
29
- if ($url && strpos($url, 'http') === 0)
30
- return $url;
31
- }
32
  }
33
  }
34
  }
35
-
36
- if (fifu_show_internal_instead_of_external(get_the_ID()))
37
- return $att_url;
38
-
39
- if ($att_id == get_post_thumbnail_id(get_the_ID())) {
40
- $url = fifu_main_image_url(get_the_ID());
41
- if ($url)
42
- $att_url = $url;
43
- }
44
  return $att_url;
45
  }
46
 
@@ -73,43 +60,25 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
73
 
74
  $post = get_post($att_id);
75
 
76
- if (fifu_is_off('fifu_data_generation')) {
77
- if (fifu_should_hide())
78
- return null;
79
- $image_size = fifu_get_image_size($size);
80
- if (fifu_is_on('fifu_original')) {
81
- return array(
82
- strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
83
- null,
84
- null,
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
  }
97
-
98
- if (fifu_show_internal_instead_of_external(get_the_ID()))
99
- return $image;
100
-
101
- if ($att_id == get_post_thumbnail_id(get_the_ID())) {
102
- $url = fifu_main_image_url(get_the_ID());
103
- if ($url) {
104
- return array(
105
- $url,
106
- 0,
107
- 0,
108
- false
109
- );
110
- }
111
- }
112
- return $image;
113
  }
114
 
115
  function fifu_is_internal_image($image) {
@@ -139,6 +108,10 @@ function fifu_get_width_height($dimension) {
139
  $dimension = null;
140
  $width = fifu_maximum('width');
141
  $height = fifu_maximum('height');
 
 
 
 
142
  }
143
  return array('width' => $width, 'height' => $height);
144
  }
5
  add_filter('get_attached_file', 'fifu_replace_attached_file', 10, 2);
6
 
7
  function fifu_replace_attached_file($att_url, $att_id) {
8
+ if ($att_url) {
9
+ $url = explode(";", $att_url);
10
+ if (sizeof($url) > 1)
11
+ return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
 
 
12
  }
13
  return $att_url;
14
  }
16
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
17
 
18
  function fifu_replace_attachment_url($att_url, $att_id) {
19
+ if ($att_url) {
20
+ $url = explode(";", $att_url);
21
+ if (sizeof($url) > 1)
22
+ return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
23
+ else {
24
+ if (get_post($att_id)) {
25
+ $url = get_post($att_id)->guid;
26
+ if ($url && strpos($url, 'http') === 0)
27
+ return $url;
 
 
28
  }
29
  }
30
  }
 
 
 
 
 
 
 
 
 
31
  return $att_url;
32
  }
33
 
60
 
61
  $post = get_post($att_id);
62
 
63
+ if (fifu_should_hide())
64
+ return null;
65
+ $image_size = fifu_get_image_size($size);
66
+ if (fifu_is_on('fifu_original')) {
 
 
 
 
 
 
 
 
 
 
67
  return array(
68
  strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
69
+ null,
70
+ null,
71
+ null,
72
  );
73
  }
74
+ $dimension = $post ? get_post_meta($post, 'fifu_image_dimension') : null;
75
+ $arrFIFU = fifu_get_width_height($dimension);
76
+ return array(
77
+ strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
78
+ !$dimension && isset($image_size['width']) && $image_size['width'] < $arrFIFU['width'] ? $image_size['width'] : $arrFIFU['width'],
79
+ !$dimension && isset($image_size['height']) && $image_size['height'] < $arrFIFU['height'] ? $image_size['height'] : $arrFIFU['height'],
80
+ isset($image_size['crop']) ? $image_size['crop'] : '',
81
+ );
 
 
 
 
 
 
 
 
82
  }
83
 
84
  function fifu_is_internal_image($image) {
108
  $dimension = null;
109
  $width = fifu_maximum('width');
110
  $height = fifu_maximum('height');
111
+
112
+ // a value is required, otherwise the zoom doesn't work
113
+ if (!$width)
114
+ $width = 1000;
115
  }
116
  return array('width' => $width, 'height' => $height);
117
  }
includes/external-post.php CHANGED
@@ -105,11 +105,6 @@ function fifu_first_url_in_content($post_id) {
105
  }
106
 
107
  function fifu_update_fake_attach_id($post_id) {
108
- if (fifu_is_on('fifu_data_generation')) {
109
- if (get_option('fifu_fake_attach_id') && !get_post_thumbnail_id($post_id))
110
- set_post_thumbnail($post_id, get_option('fifu_fake_attach_id'));
111
- return;
112
- }
113
  fifu_db_update_fake_attach_id($post_id);
114
  }
115
 
105
  }
106
 
107
  function fifu_update_fake_attach_id($post_id) {
 
 
 
 
 
108
  fifu_db_update_fake_attach_id($post_id);
109
  }
110
 
includes/thumbnail.php CHANGED
@@ -44,27 +44,6 @@ function fifu_apply_css() {
44
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {visibility:hidden;}</style>';
45
  }
46
 
47
- add_action('the_post', 'fifu_choose');
48
-
49
- function fifu_choose($post) {
50
- if (fifu_is_off('fifu_data_generation'))
51
- return;
52
-
53
- $post_id = $post->ID;
54
-
55
- $image_url = fifu_main_image_url($post_id);
56
-
57
- $featured_image = get_post_meta($post_id, '_thumbnail_id', true);
58
-
59
- if ($image_url || (get_option('fifu_default_url') && fifu_is_on('fifu_enable_default_url'))) {
60
- if (!$featured_image)
61
- update_post_meta($post_id, '_thumbnail_id', -1);
62
- } else {
63
- if ($featured_image == -1)
64
- delete_post_meta($post_id, '_thumbnail_id');
65
- }
66
- }
67
-
68
  add_filter('woocommerce_product_get_image', 'fifu_woo_replace', 10, 5);
69
 
70
  function fifu_woo_replace($html, $product, $woosize) {
@@ -82,30 +61,26 @@ function fifu_replace($html, $post_id, $post_thumbnail_id, $size) {
82
  } else
83
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
84
 
85
- if (fifu_is_off('fifu_data_generation')) {
86
- $width = fifu_get_attribute('width', $html);
87
- $height = fifu_get_attribute('height', $html);
88
-
89
- if (fifu_is_on('fifu_lazy') && !is_admin())
90
- $html = str_replace("src", "data-src", $html);
91
 
92
- $css = get_option('fifu_css');
 
93
 
94
- if ($url) {
95
- if (fifu_is_on('fifu_class')) {
96
- if (strpos($html, 'class='))
97
- $html = preg_replace('/class=[\'\"][^[\'\"]*[\'\"]/', 'class="fifu-class"', $html);
98
- else
99
- $html = str_replace('<img', '<img class="fifu-class"', $html);
100
- }
101
 
102
- return $css ? str_replace('/>', ' style="' . $css . '"/>', $html) : $html;
 
 
 
 
 
103
  }
104
 
105
- return !$url ? $html : fifu_get_html($url, $alt, $width, $height);
106
  }
107
 
108
- return !$url || fifu_show_internal_instead_of_external($post_id) ? $html : fifu_get_html($url, $alt, null, null);
109
  }
110
 
111
  function is_ajax_call() {
@@ -119,11 +94,7 @@ function fifu_get_html($url, $alt, $width, $height) {
119
  $css = 'display:none';
120
  }
121
 
122
- if (fifu_is_off('fifu_data_generation')) {
123
- return sprintf('<!-- Powered by Featured Image from URL plugin --> <img %s alt="%s" title="%s" style="%s" data-large_image="%s" data-large_image_width="%s" data-large_image_height="%s" onerror="%s" width="%s" height="%s">', fifu_lazy_url($url), $alt, $alt, $css, $url, "800", "600", "jQuery(this).hide();", $width, $height);
124
- }
125
-
126
- return sprintf('<!-- Featured Image from URL plugin --> <img %s alt="%s" title="%s" style="%s">', fifu_lazy_url($url), $alt, $alt, $css);
127
  }
128
 
129
  add_filter('the_content', 'fifu_add_to_content');
@@ -160,14 +131,8 @@ function fifu_is_main_page() {
160
  }
161
 
162
  function fifu_has_internal_image($post_id) {
163
- $att_id = get_post_meta($post_id, '_thumbnail_id', true);
164
- return $att_id && $att_id != -1 && $att_id != get_option('fifu_fake_attach_id') && (get_post($att_id) && get_post($att_id)->post_author != 77777);
165
- }
166
-
167
- function fifu_show_internal_instead_of_external($post_id) {
168
- if (!fifu_has_internal_image($post_id))
169
- return false;
170
- return fifu_is_in_editor();
171
  }
172
 
173
  function fifu_is_in_editor() {
44
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {visibility:hidden;}</style>';
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  add_filter('woocommerce_product_get_image', 'fifu_woo_replace', 10, 5);
48
 
49
  function fifu_woo_replace($html, $product, $woosize) {
61
  } else
62
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
63
 
64
+ $width = fifu_get_attribute('width', $html);
65
+ $height = fifu_get_attribute('height', $html);
 
 
 
 
66
 
67
+ if (fifu_is_on('fifu_lazy') && !is_admin())
68
+ $html = str_replace("src", "data-src", $html);
69
 
70
+ $css = get_option('fifu_css');
 
 
 
 
 
 
71
 
72
+ if ($url) {
73
+ if (fifu_is_on('fifu_class')) {
74
+ if (strpos($html, 'class='))
75
+ $html = preg_replace('/class=[\'\"][^[\'\"]*[\'\"]/', 'class="fifu-class"', $html);
76
+ else
77
+ $html = str_replace('<img', '<img class="fifu-class"', $html);
78
  }
79
 
80
+ return $css ? str_replace('/>', ' style="' . $css . '"/>', $html) : $html;
81
  }
82
 
83
+ return !$url ? $html : fifu_get_html($url, $alt, $width, $height);
84
  }
85
 
86
  function is_ajax_call() {
94
  $css = 'display:none';
95
  }
96
 
97
+ return sprintf('<!-- Powered by Featured Image from URL plugin --> <img %s alt="%s" title="%s" style="%s" data-large_image="%s" data-large_image_width="%s" data-large_image_height="%s" onerror="%s" width="%s" height="%s">', fifu_lazy_url($url), $alt, $alt, $css, $url, "800", "600", "jQuery(this).hide();", $width, $height);
 
 
 
 
98
  }
99
 
100
  add_filter('the_content', 'fifu_add_to_content');
131
  }
132
 
133
  function fifu_has_internal_image($post_id) {
134
+ $featured_image = get_post_meta($post_id, '_thumbnail_id', true);
135
+ return $featured_image && $featured_image != -1 && $featured_image != get_option('fifu_fake_attach_id');
 
 
 
 
 
 
136
  }
137
 
138
  function fifu_is_in_editor() {
readme.txt CHANGED
@@ -159,6 +159,9 @@ Features:
159
 
160
  == Changelog ==
161
 
 
 
 
162
  = 2.7.5 =
163
  * Improvement: menu settings is faster now; Bug fix: conflict with internal images in some sites.
164
 
@@ -654,6 +657,9 @@ was removed. To finish, a Premium version is now been presented.
654
 
655
  == Upgrade Notice ==
656
 
 
 
 
657
  = 2.7.5 =
658
  * Improvement: menu settings is faster now; Bug fix: conflict with internal images in some sites.
659
 
159
 
160
  == Changelog ==
161
 
162
+ = 2.7.6 =
163
+ * New: Getting Started; New FREE Feature: Admin Area > Database; Bug Fix: WooCommerce zoom; Deprecated: Fake Internal Featured Image (1 attachment for all); Improvement: faster menu settings.
164
+
165
  = 2.7.5 =
166
  * Improvement: menu settings is faster now; Bug fix: conflict with internal images in some sites.
167
 
657
 
658
  == Upgrade Notice ==
659
 
660
+ = 2.7.6 =
661
+ * New: Getting Started; New FREE Feature: Admin Area > Database; Bug Fix: WooCommerce zoom; Deprecated: Fake Internal Featured Image (1 attachment for all); Improvement: faster menu settings.
662
+
663
  = 2.7.5 =
664
  * Improvement: menu settings is faster now; Bug fix: conflict with internal images in some sites.
665