Featured Image From URL - Version 3.1.9

Version Description

  • Improvement: Lazy Load (performance and compatibility); deprecated: URL Parameters; bug fix: Default Featured Image not working for IFTTT posts.
Download this release

Release Info

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

Code changes from version 3.1.8 to 3.1.9

admin/db.php CHANGED
@@ -684,7 +684,7 @@ class FifuDb {
684
  $url = fifu_main_image_url($post_id);
685
  $has_fifu_attachment = $att_id ? ($this->is_fifu_attachment($att_id) && get_option('fifu_default_attach_id') != $att_id) : false;
686
  // delete
687
- if (!$url) {
688
  if ($has_fifu_attachment) {
689
  wp_delete_attachment($att_id);
690
  delete_post_thumbnail($post_id);
684
  $url = fifu_main_image_url($post_id);
685
  $has_fifu_attachment = $att_id ? ($this->is_fifu_attachment($att_id) && get_option('fifu_default_attach_id') != $att_id) : false;
686
  // delete
687
+ if (!$url || $url == get_option('fifu_default_url')) {
688
  if ($has_fifu_attachment) {
689
  wp_delete_attachment($att_id);
690
  delete_post_thumbnail($post_id);
admin/html/menu.html CHANGED
@@ -31,6 +31,10 @@
31
  <h2><?php esc_html_e('Feature of the month', 'featured-image-from-url'); ?></h2>
32
  <div class="greybox">
33
  <table>
 
 
 
 
34
  <tr>
35
  <td style="border-bottom:none;text-align:right;"><?php esc_html_e('June') ?></td>
36
  <td style="border-bottom:none"><?php esc_html_e('Giphy Search', 'featured-image-from-url'); ?></td>
@@ -246,32 +250,6 @@
246
  </table>
247
  </form>
248
  </div>
249
- <div class="box">
250
- <h2><?php esc_html_e('URL Parameters', 'featured-image-from-url'); ?></h2>
251
- <div class="greybox">
252
- <?php esc_html_e('Add some FIFU parameters to your image URLs. It only makes sense when you have a theme (or plugin) that calls the image URLs in a nonstandard way, what could break some FIFU features, such as Video, Slider, Shortcode, Add Class, Lazy Load and Same Height > Object Fit.', 'featured-image-from-url'); ?>
253
- </div>
254
- <br>
255
- <form
256
- id="fifu_form_parameters"
257
- action="javascript:void(0)"
258
- method="post">
259
- <input
260
- type="submit"
261
- href="javascript:void(0)"
262
- id="fifu_toggle_parameters"
263
- onclick="invert('parameters')"
264
- name="fifu_toggle_parameters"
265
- class="<?php echo $enable_parameters; ?>"
266
- value=""
267
- style="display:block;border:none">
268
- <input
269
- type="hidden"
270
- id="fifu_input_parameters"
271
- name="fifu_input_parameters"
272
- value="" >
273
- </form>
274
- </div>
275
  </div>
276
  <div id="tabs-b">
277
  <div class="box">
@@ -3108,19 +3086,6 @@
3108
  2) select "None".<br>
3109
  </div>
3110
  </div>
3111
- <div class="box">
3112
- <table>
3113
- <tr>
3114
- <td style="border-bottom:none;">2020-04-19</td>
3115
- <td style="border-bottom:none"><h3>Divi</h3></td>
3116
- <td style="border-bottom:none">theme</td>
3117
- </tr>
3118
- </table>
3119
- <div class="greybox" style="position: relative; top: -10px">
3120
- Lazy Load isn't working:<br>
3121
- 1) enable "FIFU Settings > Admin > Internal URL Parameters".<br>
3122
- </div>
3123
- </div>
3124
  <div class="box">
3125
  <table>
3126
  <tr>
@@ -3161,10 +3126,6 @@
3161
  <td style="border-bottom:none">theme</td>
3162
  </tr>
3163
  </table>
3164
- <div class="greybox" style="position: relative; top: -10px">
3165
- External videos are not being shown:<br>
3166
- 1) enable "FIFU Settings > Admin > Internal URL Parameters".<br>
3167
- </div>
3168
  <div class="greybox" style="position: relative; top: -10px">
3169
  Video lightbox isn't shown ("n.fancybox.getInstance is not a function" error):<br>
3170
  1) access "orienko/includes/head-media.php";<br>
@@ -3286,19 +3247,6 @@
3286
  5) set "_thumbnail_id" for "Post Meta to ignore".
3287
  </div>
3288
  </div>
3289
- <div class="box">
3290
- <table>
3291
- <tr>
3292
- <td style="border-bottom:none">2020-01-11</td>
3293
- <td style="border-bottom:none"><h3>Newspaper</h3></td>
3294
- <td style="border-bottom:none">theme</td>
3295
- </tr>
3296
- </table>
3297
- <div class="greybox" style="position: relative; top: -10px">
3298
- The options "show top" and "show bottom", related to "Same Height > Object Fit > Cover", are not working:<br>
3299
- 1) enable "FIFU settings > Internal URL Parameters".<br>
3300
- </div>
3301
- </div>
3302
  <div class="box">
3303
  <table>
3304
  <tr>
31
  <h2><?php esc_html_e('Feature of the month', 'featured-image-from-url'); ?></h2>
32
  <div class="greybox">
33
  <table>
34
+ <tr>
35
+ <td style="border-bottom:none;text-align:right;"><?php esc_html_e('July') ?></td>
36
+ <td style="border-bottom:none"><?php esc_html_e('full integration between Featured Slider and Lazy Load', 'featured-image-from-url'); ?></td>
37
+ </tr>
38
  <tr>
39
  <td style="border-bottom:none;text-align:right;"><?php esc_html_e('June') ?></td>
40
  <td style="border-bottom:none"><?php esc_html_e('Giphy Search', 'featured-image-from-url'); ?></td>
250
  </table>
251
  </form>
252
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  </div>
254
  <div id="tabs-b">
255
  <div class="box">
3086
  2) select "None".<br>
3087
  </div>
3088
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
3089
  <div class="box">
3090
  <table>
3091
  <tr>
3126
  <td style="border-bottom:none">theme</td>
3127
  </tr>
3128
  </table>
 
 
 
 
3129
  <div class="greybox" style="position: relative; top: -10px">
3130
  Video lightbox isn't shown ("n.fancybox.getInstance is not a function" error):<br>
3131
  1) access "orienko/includes/head-media.php";<br>
3247
  5) set "_thumbnail_id" for "Post Meta to ignore".
3248
  </div>
3249
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
3250
  <div class="box">
3251
  <table>
3252
  <tr>
admin/html/support-data.html CHANGED
@@ -45,7 +45,6 @@ fifu_lazy:<?php echo $enable_lazy ?>;
45
  fifu_media_library:<?php echo $enable_media_library ?>;
46
  fifu_original:<?php echo $enable_original ?>;
47
  fifu_ovw_first:<?php echo $enable_ovw_first ?>;
48
- fifu_parameters:<?php echo $enable_parameters ?>;
49
  fifu_pop_first:<?php echo $enable_pop_first ?>;
50
  fifu_query_strings:<?php echo $enable_query_strings ?>;
51
  fifu_run_delete_all:<?php echo $enable_run_delete_all ?>;
45
  fifu_media_library:<?php echo $enable_media_library ?>;
46
  fifu_original:<?php echo $enable_original ?>;
47
  fifu_ovw_first:<?php echo $enable_ovw_first ?>;
 
48
  fifu_pop_first:<?php echo $enable_pop_first ?>;
49
  fifu_query_strings:<?php echo $enable_query_strings ?>;
50
  fifu_run_delete_all:<?php echo $enable_run_delete_all ?>;
admin/menu.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_original', 'fifu_lazy', 'fifu_jquery', 'fifu_media_library', 'fifu_parameters', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_css', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_class', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean', '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
 
@@ -40,7 +40,6 @@ function fifu_support_data() {
40
  $enable_lazy = get_option('fifu_lazy');
41
  $enable_jquery = get_option('fifu_jquery');
42
  $enable_media_library = get_option('fifu_media_library');
43
- $enable_parameters = get_option('fifu_parameters');
44
  $enable_content = get_option('fifu_content');
45
  $enable_content_page = get_option('fifu_content_page');
46
  $enable_fake = get_option('fifu_fake');
@@ -97,7 +96,6 @@ function fifu_get_menu_html() {
97
  $enable_lazy = get_option('fifu_lazy');
98
  $enable_jquery = get_option('fifu_jquery');
99
  $enable_media_library = get_option('fifu_media_library');
100
- $enable_parameters = get_option('fifu_parameters');
101
  $enable_content = get_option('fifu_content');
102
  $enable_content_page = get_option('fifu_content_page');
103
  $enable_fake = get_option('fifu_fake');
@@ -132,9 +130,10 @@ function fifu_get_menu_html() {
132
 
133
  include 'html/menu.html';
134
 
135
- fifu_update_menu_options();
136
 
137
  // default
 
138
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake')) {
139
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
140
  $att_id = fifu_db_create_attachment($default_url);
@@ -188,7 +187,6 @@ function fifu_update_menu_options() {
188
  fifu_update_option('fifu_input_lazy', 'fifu_lazy');
189
  fifu_update_option('fifu_input_jquery', 'fifu_jquery');
190
  fifu_update_option('fifu_input_media_library', 'fifu_media_library');
191
- fifu_update_option('fifu_input_parameters', 'fifu_parameters');
192
  fifu_update_option('fifu_input_content', 'fifu_content');
193
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
194
  fifu_update_option('fifu_input_fake', 'fifu_fake');
@@ -226,6 +224,12 @@ function fifu_update_menu_options() {
226
  // delete all run log
227
  if (fifu_is_on('fifu_run_delete_all'))
228
  update_option('fifu_run_delete_all_time', current_time('mysql'), 'no');
 
 
 
 
 
 
229
  }
230
 
231
  function fifu_update_option($input, $type) {
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_original', 'fifu_lazy', 'fifu_jquery', 'fifu_media_library', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_css', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_class', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean', '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
 
40
  $enable_lazy = get_option('fifu_lazy');
41
  $enable_jquery = get_option('fifu_jquery');
42
  $enable_media_library = get_option('fifu_media_library');
 
43
  $enable_content = get_option('fifu_content');
44
  $enable_content_page = get_option('fifu_content_page');
45
  $enable_fake = get_option('fifu_fake');
96
  $enable_lazy = get_option('fifu_lazy');
97
  $enable_jquery = get_option('fifu_jquery');
98
  $enable_media_library = get_option('fifu_media_library');
 
99
  $enable_content = get_option('fifu_content');
100
  $enable_content_page = get_option('fifu_content_page');
101
  $enable_fake = get_option('fifu_fake');
130
 
131
  include 'html/menu.html';
132
 
133
+ $arr = fifu_update_menu_options();
134
 
135
  // default
136
+ $default_url = $arr['fifu_default_url'];
137
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake')) {
138
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
139
  $att_id = fifu_db_create_attachment($default_url);
187
  fifu_update_option('fifu_input_lazy', 'fifu_lazy');
188
  fifu_update_option('fifu_input_jquery', 'fifu_jquery');
189
  fifu_update_option('fifu_input_media_library', 'fifu_media_library');
 
190
  fifu_update_option('fifu_input_content', 'fifu_content');
191
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
192
  fifu_update_option('fifu_input_fake', 'fifu_fake');
224
  // delete all run log
225
  if (fifu_is_on('fifu_run_delete_all'))
226
  update_option('fifu_run_delete_all_time', current_time('mysql'), 'no');
227
+
228
+ // urgent updates
229
+ $arr = array();
230
+ $arr['fifu_default_url'] = isset($_POST['fifu_input_default_url']) ? wp_strip_all_tags($_POST['fifu_input_default_url']) : '';
231
+
232
+ return $arr;
233
  }
234
 
235
  function fifu_update_option($input, $type) {
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image as Featured Image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
7
- * Version: 3.1.8
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image as Featured Image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
7
+ * Version: 3.1.9
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
includes/attachment.php CHANGED
@@ -17,8 +17,7 @@ function fifu_replace_attachment_url($att_url, $att_id) {
17
  if ($att_url) {
18
  $url = explode(";", $att_url);
19
  if (sizeof($url) > 1) {
20
- if (fifu_is_on('fifu_parameters'))
21
- $url[1] = fifu_add_url_parameters($url[1], $att_id);
22
  return fifu_has_internal_image_path($url[1]) ? get_post($att_id)->guid : $url[1];
23
  } else {
24
  $post = get_post($att_id);
@@ -136,30 +135,25 @@ function fifu_callback($buffer) {
136
  if (empty($buffer))
137
  return;
138
 
139
- if (is_singular('product') && fifu_is_off('fifu_lazy') && fifu_is_off('fifu_parameters'))
140
- return $buffer;
141
-
142
  $imgList = array();
143
  preg_match_all('/<img[^>]*>/', $buffer, $imgList);
144
- $srcArray = array(
145
- "src" => "src",
146
- "data-src" => "data-src"
147
- );
148
  foreach ($imgList[0] as $imgItem) {
149
- foreach ($srcArray as $srcItem) {
150
- preg_match('/(' . $srcItem . ')([^\'\"]*[\'\"]){2}/', $imgItem, $src);
151
- if (!$src)
152
- continue;
153
- $delimiter = substr($src[0], - 1);
154
- $url = explode($delimiter, $src[0])[1];
155
- if (strpos($url, 'fifu-post-id') === false)
156
- continue;
157
- $id = explode('&', explode('fifu-post-id=', $url)[1])[0];
158
- $featured = explode('&', explode('fifu-featured=', $url)[1])[0];
159
- if (!(int) $featured)
160
- continue;
161
- $buffer = str_replace($imgItem, fifu_replace($imgItem, $id, null, null), $buffer);
162
- }
163
  }
164
 
165
  if (fifu_is_on('fifu_lazy')) {
@@ -169,13 +163,21 @@ function fifu_callback($buffer) {
169
  foreach ($imgList[0] as $imgItem) {
170
  $mainDelimiter = substr(explode('style=', $imgItem)[1], 0, 1);
171
  $subDelimiter = substr(explode('url(', $imgItem)[1], 0, 1);
172
- if ($subDelimiter)
173
  $url = preg_split('/[\'\" ]{1}\)/', preg_split('/url\([\'\" ]{1}/', $imgItem, -1)[1], -1)[0];
174
  else
175
  $url = preg_split('/\)/', preg_split('/url\(/', $imgItem, -1)[1], -1)[0];
176
- $newImgItem = preg_replace("/background-image[^:]*:[^\)]*url[^\)]*[\)]/", "", $imgItem);
 
 
 
177
  $attr = 'data-bg=' . $mainDelimiter . $url . $mainDelimiter;
178
  $newImgItem = str_replace('>', ' ' . $attr . '>', $newImgItem);
 
 
 
 
 
179
  $buffer = str_replace($imgItem, $newImgItem, $buffer);
180
  }
181
  }
17
  if ($att_url) {
18
  $url = explode(";", $att_url);
19
  if (sizeof($url) > 1) {
20
+ $url[1] = fifu_add_url_parameters($url[1], $att_id);
 
21
  return fifu_has_internal_image_path($url[1]) ? get_post($att_id)->guid : $url[1];
22
  } else {
23
  $post = get_post($att_id);
135
  if (empty($buffer))
136
  return;
137
 
138
+ $srcType = "src";
 
 
139
  $imgList = array();
140
  preg_match_all('/<img[^>]*>/', $buffer, $imgList);
141
+
 
 
 
142
  foreach ($imgList[0] as $imgItem) {
143
+ preg_match('/(' . $srcType . ')([^\'\"]*[\'\"]){2}/', $imgItem, $src);
144
+ if (!$src)
145
+ continue;
146
+ $del = substr($src[0], - 1);
147
+ $url = explode($del, $src[0])[1];
148
+
149
+ if (strpos($url, 'fifu-post-id') === false)
150
+ continue;
151
+
152
+ $post_id = explode('&', explode('fifu-post-id=', $url)[1])[0];
153
+
154
+ // featured media
155
+ if (strpos($url, 'fifu-featured=1') !== false)
156
+ $buffer = str_replace($imgItem, fifu_replace($imgItem, $post_id, null, null), $buffer);
157
  }
158
 
159
  if (fifu_is_on('fifu_lazy')) {
163
  foreach ($imgList[0] as $imgItem) {
164
  $mainDelimiter = substr(explode('style=', $imgItem)[1], 0, 1);
165
  $subDelimiter = substr(explode('url(', $imgItem)[1], 0, 1);
166
+ if (in_array($subDelimiter, array('"', "'", ' ')))
167
  $url = preg_split('/[\'\" ]{1}\)/', preg_split('/url\([\'\" ]{1}/', $imgItem, -1)[1], -1)[0];
168
  else
169
  $url = preg_split('/\)/', preg_split('/url\(/', $imgItem, -1)[1], -1)[0];
170
+
171
+ $class = 'lazyload ';
172
+
173
+ $newImgItem = str_replace('class=' . $mainDelimiter, 'class=' . $mainDelimiter . $class, $imgItem);
174
  $attr = 'data-bg=' . $mainDelimiter . $url . $mainDelimiter;
175
  $newImgItem = str_replace('>', ' ' . $attr . '>', $newImgItem);
176
+
177
+ // remove background-image
178
+ $pattern = '/background-image.*url\(' . $subDelimiter . '.*' . $subDelimiter . '\)/';
179
+ $newImgItem = preg_replace($pattern, '', $newImgItem);
180
+
181
  $buffer = str_replace($imgItem, $newImgItem, $buffer);
182
  }
183
  }
includes/external-post.php CHANGED
@@ -35,7 +35,11 @@ function fifu_save_properties_ext($post_id) {
35
  if ($url && fifu_is_on('fifu_get_first')) {
36
  update_post_meta($post_id, 'fifu_image_url', fifu_convert($url));
37
  fifu_update_fake_attach_id($post_id);
 
38
  }
 
 
 
39
  }
40
 
41
  function fifu_first_img_in_content($content) {
35
  if ($url && fifu_is_on('fifu_get_first')) {
36
  update_post_meta($post_id, 'fifu_image_url', fifu_convert($url));
37
  fifu_update_fake_attach_id($post_id);
38
+ return;
39
  }
40
+
41
+ if (!$url && get_option('fifu_default_url') && fifu_is_on('fifu_enable_default_url'))
42
+ fifu_update_fake_attach_id($post_id);
43
  }
44
 
45
  function fifu_first_img_in_content($content) {
includes/html/css/lazyload.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .lazyload,
2
+ .lazyloading {
3
+ opacity: 0;
4
+ }
5
+
6
+ .lazyloaded {
7
+ opacity: 1;
8
+ transition: opacity 300ms;
9
+ }
10
+
11
+ .lazyload {
12
+ opacity: 0;
13
+ }
14
+
15
+ .lazyloading {
16
+ opacity: 1;
17
+ transition: opacity 300ms;
18
+ background: #f7f7f7 url('../../images/loading.gif') no-repeat center;
19
+ }
includes/html/js/image.js CHANGED
@@ -1,17 +1,7 @@
1
  jQuery(document).ready(function ($) {
2
  // lazy load
3
- if (fifuImageVars.fifu_lazy) {
4
- jQuery.extend(jQuery.lazyLoadXT, {
5
- srcAttr: 'data-src',
6
- visibleOnly: false,
7
- updateEvent: 'load orientationchange resize scroll touchmove focus hover'
8
- });
9
-
10
- // storefront theme
11
- jQuery("ul#site-header-cart").on('hover', function (evt) {
12
- jQuery(window).lazyLoadXT();
13
- });
14
- }
15
 
16
  // woocommerce lightbox/zoom
17
  disableClick($);
@@ -32,14 +22,19 @@ jQuery(document).ready(function ($) {
32
  jQuery(window).on('ajaxComplete', function () {
33
  if (fifuImageVars.fifu_lazy) {
34
  setTimeout(function () {
35
- jQuery(window).lazyLoadXT();
36
  }, 300);
37
  }
38
  });
39
 
40
- jQuery(window).on('load', function () {
41
- jQuery('.flex-viewport').css('height', '100%');
42
- });
 
 
 
 
 
43
 
44
  function resizeImg($) {
45
  var imgSelector = ".post img, .page img, .widget-content img, .product img, .wp-admin img, .tax-product_cat img, .fifu img";
1
  jQuery(document).ready(function ($) {
2
  // lazy load
3
+ if (fifuImageVars.fifu_lazy)
4
+ fifu_lazy();
 
 
 
 
 
 
 
 
 
 
5
 
6
  // woocommerce lightbox/zoom
7
  disableClick($);
22
  jQuery(window).on('ajaxComplete', function () {
23
  if (fifuImageVars.fifu_lazy) {
24
  setTimeout(function () {
25
+ fifu_lazy();
26
  }, 300);
27
  }
28
  });
29
 
30
+ // fix space between product image and gallery caused by lazy load
31
+ if (fifuImageVars.fifu_is_product) {
32
+ jQuery('img[data-src*="featured=1"]').on('load', function () {
33
+ mainImage = jQuery('.flex-viewport').find('img[data-src*="featured=1"]')[0];
34
+ if (mainImage)
35
+ jQuery('.flex-viewport').css('height', mainImage.clientHeight + 'px');
36
+ });
37
+ }
38
 
39
  function resizeImg($) {
40
  var imgSelector = ".post img, .page img, .widget-content img, .product img, .wp-admin img, .tax-product_cat img, .fifu img";
includes/html/js/lazySizesConfig.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function () {
2
+ window.lazySizesConfig = window.lazySizesConfig || {};
3
+ window.lazySizesConfig.loadMode = 1;
4
+ window.lazySizesConfig.expand = 1;
5
+ window.lazySizesConfig.expFactor = 0.1;
6
+ window.lazySizesConfig.hFac = 0.1;
7
+ window.lazySizesConfig.throttleDelay = 0;
8
+ })();
9
+
10
+ function fifu_lazy() {
11
+ jQuery('img').each(function (index) {
12
+ fifu_add_placeholder(this);
13
+ // dont touch on slider
14
+ if (!jQuery(this).hasClass('fifu'))
15
+ fifu_add_lazyload(this);
16
+ });
17
+
18
+ jQuery('a[data-bg], div[data-bg]').each(function (index) {
19
+ fifu_add_lazyload(this);
20
+ });
21
+ }
22
+
23
+ function fifu_add_lazyload($) {
24
+ jQuery($).addClass('lazyload');
25
+ }
26
+
27
+ function fifu_add_placeholder($) {
28
+ clazz = jQuery($).attr('class');
29
+ src = jQuery($).attr('src');
30
+ datasrc = jQuery($).attr('data-src');
31
+ if (!src && datasrc)
32
+ jQuery($).attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
33
+ }
34
+
35
+ document.addEventListener('lazybeforeunveil', function (e) {
36
+ // background-image
37
+ var url = jQuery(e.target).attr('data-bg');
38
+ if (url) {
39
+ delimiter = fifu_get_delimiter(jQuery(e.target), 'data-bg');
40
+ jQuery(e.target).css('background-image', 'url(' + fifu_get_delimited_url(url, delimiter) + ')');
41
+ }
42
+
43
+ // width & height
44
+ jQuery(e.target).attr('fifu-width', e.srcElement.clientWidth);
45
+ jQuery(e.target).attr('fifu-height', e.srcElement.clientHeight);
46
+ });
47
+
48
+ function fifu_get_delimiter($, attr) {
49
+ return $[0].outerHTML.split(attr + '=')[1][0];
50
+ }
51
+
52
+ function fifu_get_delimited_url(url, delimiter) {
53
+ return delimiter + url + delimiter;
54
+ }
includes/images/loading.gif ADDED
Binary file
includes/thumbnail.php CHANGED
@@ -19,15 +19,18 @@ if (!in_array($pagenow, array('post.php', 'post-new.php', 'admin-ajax.php', 'wp-
19
  add_filter('wp_head', 'fifu_apply_css');
20
 
21
  function fifu_add_js() {
 
 
22
  if (fifu_is_on('fifu_lazy')) {
23
- wp_enqueue_script('lazyload', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyloadxt/1.1.0/jquery.lazyloadxt.min.js');
24
- wp_enqueue_script('lazyload-bg', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyloadxt/1.1.0/jquery.lazyloadxt.bg.min.js');
25
- wp_enqueue_script('lazyload-srcset', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyloadxt/1.1.0/jquery.lazyloadxt.srcset.min.js');
26
- wp_enqueue_style('lazyload-spinner', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyloadxt/1.1.0/jquery.lazyloadxt.spinner.min.css');
 
27
  }
28
 
29
  // css
30
- wp_register_style('fifu-woo-css', plugins_url('/html/css/woo.css', __FILE__));
31
  wp_enqueue_style('fifu-woo-css');
32
  wp_add_inline_style('fifu-woo-css', 'img.zoomImg {display:' . fifu_woo_zoom() . ' !important}');
33
 
@@ -37,6 +40,7 @@ function fifu_add_js() {
37
  'fifu_lazy' => fifu_is_on("fifu_lazy"),
38
  'fifu_woo_lbox_enabled' => fifu_woo_lbox(),
39
  'fifu_woo_zoom' => fifu_woo_zoom(),
 
40
  ]);
41
  }
42
 
@@ -127,10 +131,6 @@ function fifu_replace($html, $post_id, $post_thumbnail_id, $size) {
127
  return !$url ? $html : fifu_get_html($url, $alt, $width, $height);
128
  }
129
 
130
- function is_ajax_call() {
131
- return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || wp_doing_ajax();
132
- }
133
-
134
  function fifu_get_html($url, $alt, $width, $height) {
135
  $css = get_option('fifu_css');
136
 
@@ -171,9 +171,9 @@ function fifu_no_internal_image($post_id) {
171
  }
172
 
173
  function fifu_lazy_url($url) {
174
- if (fifu_is_off('fifu_lazy') || is_ajax_call())
175
  return 'src="' . $url . '"';
176
- return (fifu_is_main_page() ? 'data-src="' : 'src="') . $url . '"';
177
  }
178
 
179
  function fifu_is_main_page() {
19
  add_filter('wp_head', 'fifu_apply_css');
20
 
21
  function fifu_add_js() {
22
+ echo '<link rel="preconnect" href="https://cdnjs.cloudflare.com">';
23
+
24
  if (fifu_is_on('fifu_lazy')) {
25
+ wp_enqueue_style('lazyload-spinner', plugins_url('/html/css/lazyload.css?' . fifu_version_number(), __FILE__));
26
+ wp_enqueue_script('lazysizes-config', plugins_url('/html/js/lazySizesConfig.js?' . fifu_version_number(), __FILE__));
27
+ wp_enqueue_script('unveilhooks', 'https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/plugins/unveilhooks/ls.unveilhooks.min.js');
28
+ wp_enqueue_script('lazysizes', 'https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/lazysizes.min.js');
29
+ // wp_enqueue_script('bgset', 'https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/plugins/bgset/ls.bgset.min.js');
30
  }
31
 
32
  // css
33
+ wp_register_style('fifu-woo-css', plugins_url('/html/css/woo.css?' . fifu_version_number(), __FILE__));
34
  wp_enqueue_style('fifu-woo-css');
35
  wp_add_inline_style('fifu-woo-css', 'img.zoomImg {display:' . fifu_woo_zoom() . ' !important}');
36
 
40
  'fifu_lazy' => fifu_is_on("fifu_lazy"),
41
  'fifu_woo_lbox_enabled' => fifu_woo_lbox(),
42
  'fifu_woo_zoom' => fifu_woo_zoom(),
43
+ 'fifu_is_product' => class_exists('WooCommerce') && is_product(),
44
  ]);
45
  }
46
 
131
  return !$url ? $html : fifu_get_html($url, $alt, $width, $height);
132
  }
133
 
 
 
 
 
134
  function fifu_get_html($url, $alt, $width, $height) {
135
  $css = get_option('fifu_css');
136
 
171
  }
172
 
173
  function fifu_lazy_url($url) {
174
+ if (fifu_is_off('fifu_lazy'))
175
  return 'src="' . $url . '"';
176
+ return 'data-src="' . $url . '"';
177
  }
178
 
179
  function fifu_is_main_page() {
includes/util.php CHANGED
@@ -62,6 +62,10 @@ function fifu_get_delimiter($property, $html) {
62
  return $delimiter ? substr($delimiter[1], 0, 1) : null;
63
  }
64
 
 
 
 
 
65
  /* dimensions */
66
 
67
  function fifu_curl($url) {
@@ -103,4 +107,3 @@ function fifu_is_elementor_editor() {
103
  return false;
104
  return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
105
  }
106
-
62
  return $delimiter ? substr($delimiter[1], 0, 1) : null;
63
  }
64
 
65
+ function fifu_is_ajax_call() {
66
+ return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || wp_doing_ajax();
67
+ }
68
+
69
  /* dimensions */
70
 
71
  function fifu_curl($url) {
107
  return false;
108
  return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
109
  }
 
languages/featured-image-from-url-pt_BR.po CHANGED
@@ -89,18 +89,6 @@ msgstr ""
89
  msgid "add social tags"
90
  msgstr "adicionar tags sociais"
91
 
92
- msgid ""
93
- "Add some FIFU parameters to your image URLs. It only makes sense when you "
94
- "have a theme (or plugin) that calls the image URLs in a nonstandard way, "
95
- "what could break some FIFU features, such as Video, Slider, Shortcode, Add "
96
- "Class, Lazy Load and Same Height > Object Fit."
97
- msgstr ""
98
- "Adicionar alguns parâmetros do FIFU aos URLs de imagem. Isso só faz sentido "
99
- "quando você tem um tema (ou plugin) que chama os URLs de imagem de maneira "
100
- "fora do padrão, o que pode quebrar algumas funcionalidades do FIFU, como "
101
- "Vídeo, Slider, Shortcode, Adição de Classe, Lazy Load e Mesma Altura> Ajuste "
102
- "do Objeto."
103
-
104
  msgid "Add the class \"fifu-class\" to the Featured Image tags."
105
  msgstr "Adicionar a classe \"fifu-class\" às tags de Imagens Destacadas."
106
 
@@ -1150,9 +1138,6 @@ msgstr "atualizar todos os seus posts agora"
1150
  msgid "URL from Post Content"
1151
  msgstr "URL no Conteúdo"
1152
 
1153
- msgid "URL Parameters"
1154
- msgstr "Parâmetros de URL"
1155
-
1156
  msgid "Use FIFU with WooCommerce import."
1157
  msgstr "Utilize FIFU com a importação do WooCommerce."
1158
 
89
  msgid "add social tags"
90
  msgstr "adicionar tags sociais"
91
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  msgid "Add the class \"fifu-class\" to the Featured Image tags."
93
  msgstr "Adicionar a classe \"fifu-class\" às tags de Imagens Destacadas."
94
 
1138
  msgid "URL from Post Content"
1139
  msgstr "URL no Conteúdo"
1140
 
 
 
 
1141
  msgid "Use FIFU with WooCommerce import."
1142
  msgstr "Utilize FIFU com a importação do WooCommerce."
1143
 
languages/featured-image-from-url.pot CHANGED
@@ -66,9 +66,6 @@ msgstr ""
66
  msgid "add social tags"
67
  msgstr ""
68
 
69
- msgid "Add some FIFU parameters to your image URLs. It only makes sense when you have a theme (or plugin) that calls the image URLs in a nonstandard way, what could break some FIFU features, such as Video, Slider, Shortcode, Add Class, Lazy Load and Same Height > Object Fit."
70
- msgstr ""
71
-
72
  msgid "Add the class "fifu-class" to the Featured Image tags."
73
  msgstr ""
74
 
@@ -897,9 +894,6 @@ msgstr ""
897
  msgid "URL from Post Content"
898
  msgstr ""
899
 
900
- msgid "URL Parameters"
901
- msgstr ""
902
-
903
  msgid "Use FIFU with WooCommerce import."
904
  msgstr ""
905
 
@@ -1113,6 +1107,9 @@ msgstr ""
1113
  msgid "German"
1114
  msgstr ""
1115
 
 
 
 
1116
  msgid "English (United States)"
1117
  msgstr ""
1118
 
66
  msgid "add social tags"
67
  msgstr ""
68
 
 
 
 
69
  msgid "Add the class "fifu-class" to the Featured Image tags."
70
  msgstr ""
71
 
894
  msgid "URL from Post Content"
895
  msgstr ""
896
 
 
 
 
897
  msgid "Use FIFU with WooCommerce import."
898
  msgstr ""
899
 
1107
  msgid "German"
1108
  msgstr ""
1109
 
1110
+ msgid "Greek"
1111
+ msgstr ""
1112
+
1113
  msgid "English (United States)"
1114
  msgstr ""
1115
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
4
  Tags: featured image, featured, image, url, link, woocommerce, product, gallery, video, slider, external, thumbnail
5
  Requires at least: 5.0
6
  Tested up to: 5.4
7
- Stable tag: 3.1.8
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -65,10 +65,6 @@ Use an external image as featured image of your post, page or custom post type.
65
  * **[Premium]** Variation image
66
  * **[Premium]** Variation image gallery
67
 
68
- #### INTEGRATION FUNCTIONS FOR DEVELOPERS
69
-
70
- * fifu_dev_set_image($post_id, $image_url)
71
-
72
  #### FEATURED VIDEO
73
  Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publitio.
74
 
@@ -90,6 +86,10 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publiti
90
  * **[Premium]** Featured slider
91
  * **[Premium]** Featured shortcode
92
 
 
 
 
 
93
  #### LANGUAGES
94
 
95
  * English (United States)
@@ -193,20 +193,20 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publiti
193
 
194
  == Changelog ==
195
 
 
 
 
196
  = 3.1.8 =
197
  * New language: Greek; improvement: readme strings added to the pot file; bug fix: conflict between lazy load and background-image.
198
 
199
  = 3.1.7 =
200
  * Improvement: development function created to make the integration with FIFU easier; bug fix: image title was not being shown; bug fix: conflict between lazy load and background-images.
201
 
202
- = 3.1.6 =
203
- * Improvement: readme changes to comply with the WordPress.org plugin guidelines.
204
-
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
- = 3.1.8 =
212
- * New language: Greek; improvement: readme strings added to the pot file; bug fix: conflict between lazy load and background-image.
4
  Tags: featured image, featured, image, url, link, woocommerce, product, gallery, video, slider, external, thumbnail
5
  Requires at least: 5.0
6
  Tested up to: 5.4
7
+ Stable tag: 3.1.9
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
65
  * **[Premium]** Variation image
66
  * **[Premium]** Variation image gallery
67
 
 
 
 
 
68
  #### FEATURED VIDEO
69
  Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publitio.
70
 
86
  * **[Premium]** Featured slider
87
  * **[Premium]** Featured shortcode
88
 
89
+ #### INTEGRATION FUNCTION FOR DEVELOPERS
90
+
91
+ * fifu_dev_set_image($post_id, $image_url)
92
+
93
  #### LANGUAGES
94
 
95
  * English (United States)
193
 
194
  == Changelog ==
195
 
196
+ = 3.1.9 =
197
+ * Improvement: Lazy Load (performance and compatibility); deprecated: URL Parameters; bug fix: Default Featured Image not working for IFTTT posts.
198
+
199
  = 3.1.8 =
200
  * New language: Greek; improvement: readme strings added to the pot file; bug fix: conflict between lazy load and background-image.
201
 
202
  = 3.1.7 =
203
  * Improvement: development function created to make the integration with FIFU easier; bug fix: image title was not being shown; bug fix: conflict between lazy load and background-images.
204
 
 
 
 
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
+ = 3.1.9 =
212
+ * Improvement: Lazy Load (performance and compatibility); deprecated: URL Parameters; bug fix: Default Featured Image not working for IFTTT posts.