Featured Image From URL - Version 3.2.0

Version Description

  • Bug fix: images from some addresses were not being shown; bug fix: URL from Post Content (hide option not working for IFTTT posts).
Download this release

Release Info

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

Code changes from version 3.1.9 to 3.2.0

featured-image-from-url.php CHANGED
@@ -4,11 +4,11 @@
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
11
- * WC tested up to: 4.2.2
12
  * Text Domain: featured-image-from-url
13
  * License: GPLv3
14
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image as Featured Image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
7
+ * Version: 3.2.0
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
11
+ * WC tested up to: 4.3.1
12
  * Text Domain: featured-image-from-url
13
  * License: GPLv3
14
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
includes/attachment.php CHANGED
@@ -145,6 +145,7 @@ function fifu_callback($buffer) {
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;
@@ -152,7 +153,7 @@ function fifu_callback($buffer) {
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
 
@@ -178,7 +179,13 @@ function fifu_callback($buffer) {
178
  $pattern = '/background-image.*url\(' . $subDelimiter . '.*' . $subDelimiter . '\)/';
179
  $newImgItem = preg_replace($pattern, '', $newImgItem);
180
 
181
- $buffer = str_replace($imgItem, $newImgItem, $buffer);
 
 
 
 
 
 
182
  }
183
  }
184
 
@@ -214,7 +221,21 @@ function fifu_get_width_height($dimension) {
214
 
215
  // for themes that dont call post_thumbnail_html
216
 
 
 
 
 
 
 
 
 
 
 
 
217
  function fifu_add_url_parameters($url, $att_id) {
 
 
 
218
  $post_id = get_post($att_id)->post_parent;
219
  if (!$post_id)
220
  return $url;
@@ -224,6 +245,10 @@ function fifu_add_url_parameters($url, $att_id) {
224
  $post_thumbnail_id = $post_thumbnail_id ? $post_thumbnail_id : get_term_meta($post_id, 'thumbnail_id', true);
225
  $featured = $post_thumbnail_id == $att_id ? 1 : 0;
226
 
 
 
 
 
227
  $url .= $symbol . 'fifu-post-id=' . $post_id . '&fifu-featured=' . $featured;
228
 
229
  return $url;
145
  continue;
146
  $del = substr($src[0], - 1);
147
  $url = explode($del, $src[0])[1];
148
+ $post_id = null;
149
 
150
  if (strpos($url, 'fifu-post-id') === false)
151
  continue;
153
  $post_id = explode('&', explode('fifu-post-id=', $url)[1])[0];
154
 
155
  // featured media
156
+ if (strpos($url, 'fifu-featured=1') !== false && $post_id)
157
  $buffer = str_replace($imgItem, fifu_replace($imgItem, $post_id, null, null), $buffer);
158
  }
159
 
179
  $pattern = '/background-image.*url\(' . $subDelimiter . '.*' . $subDelimiter . '\)/';
180
  $newImgItem = preg_replace($pattern, '', $newImgItem);
181
 
182
+ $buffer = str_replace($imgItem, fifu_remove_parameters($newImgItem), $buffer);
183
+ }
184
+ } else {
185
+ $imgList = array();
186
+ preg_match_all('/<[^>]*background-image[^>]*>/', $buffer, $imgList);
187
+ foreach ($imgList[0] as $imgItem) {
188
+ $buffer = str_replace($imgItem, fifu_remove_parameters($imgItem), $buffer);
189
  }
190
  }
191
 
221
 
222
  // for themes that dont call post_thumbnail_html
223
 
224
+ function fifu_dashboard() {
225
+ return !is_home() &&
226
+ !is_singular('post') &&
227
+ !is_author() &&
228
+ !is_search() &&
229
+ !is_singular('page') &&
230
+ !is_singular('product') &&
231
+ !is_archive() &&
232
+ (!class_exists('WooCommerce') || (class_exists('WooCommerce') && (!is_shop() && !is_product_category() && !is_cart())));
233
+ }
234
+
235
  function fifu_add_url_parameters($url, $att_id) {
236
+ if (fifu_dashboard())
237
+ return $url;
238
+
239
  $post_id = get_post($att_id)->post_parent;
240
  if (!$post_id)
241
  return $url;
245
  $post_thumbnail_id = $post_thumbnail_id ? $post_thumbnail_id : get_term_meta($post_id, 'thumbnail_id', true);
246
  $featured = $post_thumbnail_id == $att_id ? 1 : 0;
247
 
248
+ // only the main image will have parameters
249
+ if (!$featured)
250
+ return $url;
251
+
252
  $url .= $symbol . 'fifu-post-id=' . $post_id . '&fifu-featured=' . $featured;
253
 
254
  return $url;
includes/external-post.php CHANGED
@@ -4,7 +4,7 @@ add_filter('wp_insert_post_data', 'fifu_remove_first_image_ext', 10, 2);
4
 
5
  function fifu_remove_first_image_ext($data, $postarr) {
6
  /* invalid or internal or ignore */
7
- if (!$_POST || isset($_POST['fifu_input_url']) || isset($_POST['fifu_ignore_auto_set']))
8
  return $data;
9
 
10
  $content = $postarr['post_content'];
4
 
5
  function fifu_remove_first_image_ext($data, $postarr) {
6
  /* invalid or internal or ignore */
7
+ if (isset($_POST['fifu_input_url']) || isset($_POST['fifu_ignore_auto_set']))
8
  return $data;
9
 
10
  $content = $postarr['post_content'];
includes/html/js/image.js CHANGED
@@ -20,17 +20,16 @@ jQuery(document).ready(function ($) {
20
  });
21
 
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
  });
20
  });
21
 
22
  jQuery(window).on('ajaxComplete', function () {
23
+ setTimeout(function () {
24
+ if (fifuImageVars.fifu_lazy)
25
  fifu_lazy();
26
+ }, 300);
 
27
  });
28
 
29
  // fix space between product image and gallery caused by lazy load
30
  if (fifuImageVars.fifu_is_product) {
31
+ jQuery('img[fifu-featured="1"]').on('load', function () {
32
+ mainImage = jQuery('.flex-viewport').find('img[fifu-featured="1"]')[0];
33
  if (mainImage)
34
  jQuery('.flex-viewport').css('height', mainImage.clientHeight + 'px');
35
  });
includes/html/js/lazySizesConfig.js CHANGED
@@ -10,6 +10,7 @@
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);
10
  function fifu_lazy() {
11
  jQuery('img').each(function (index) {
12
  fifu_add_placeholder(this);
13
+
14
  // dont touch on slider
15
  if (!jQuery(this).hasClass('fifu'))
16
  fifu_add_lazyload(this);
includes/thumbnail.php CHANGED
@@ -96,6 +96,8 @@ function fifu_replace($html, $post_id, $post_thumbnail_id, $size) {
96
  if (!$html)
97
  return $html;
98
 
 
 
99
  $url = get_post_meta($post_id, 'fifu_image_url', true);
100
 
101
  $delimiter = fifu_get_delimiter('src', $html);
96
  if (!$html)
97
  return $html;
98
 
99
+ $html = fifu_remove_parameters($html);
100
+
101
  $url = get_post_meta($post_id, 'fifu_image_url', true);
102
 
103
  $delimiter = fifu_get_delimiter('src', $html);
includes/util.php CHANGED
@@ -66,6 +66,22 @@ 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,3 +123,4 @@ function fifu_is_elementor_editor() {
107
  return false;
108
  return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
109
  }
 
66
  return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || wp_doing_ajax();
67
  }
68
 
69
+ function fifu_remove_parameters($tag) {
70
+ // move parameters
71
+ if (strpos($tag, 'fifu-featured=1') !== false)
72
+ $tag = str_replace('<img ', '<img fifu-featured="1" ', $tag);
73
+
74
+ // remove parameters
75
+ $tag = str_replace('amp;fifu-', 'fifu-', $tag);
76
+ $tag = str_replace('#038;fifu-', 'fifu-', $tag);
77
+ $tag = preg_replace('/[\&]fifu-[^\&\"\']+/', '', $tag);
78
+ $tag = preg_replace('/[\?]fifu-[^\&\"\']+/', '?', $tag);
79
+ $tag = str_replace('?"', '"', $tag);
80
+ $tag = str_replace("?'", "'", $tag);
81
+
82
+ return $tag;
83
+ }
84
+
85
  /* dimensions */
86
 
87
  function fifu_curl($url) {
123
  return false;
124
  return \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode();
125
  }
126
+
includes/woo.php CHANGED
@@ -12,3 +12,14 @@ function fifu_woo_theme() {
12
  return file_exists(get_template_directory() . '/woocommerce');
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
 
12
  return file_exists(get_template_directory() . '/woocommerce');
13
  }
14
 
15
+ function fifu_woocommerce_gallery_image_html_attachment_image_params($params, $attachment_id, $image_size, $main_image) {
16
+ $attrList = array('src', 'data-src', 'data-large_image');
17
+ foreach ($attrList as $attr) {
18
+ if (isset($params[$attr]))
19
+ $params[$attr] = fifu_remove_parameters($params[$attr]);
20
+ }
21
+ return $params;
22
+ }
23
+
24
+ add_filter('woocommerce_gallery_image_html_attachment_image_params', 'fifu_woocommerce_gallery_image_html_attachment_image_params', 10, 4);
25
+
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.9
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -193,20 +193,20 @@ Supports videos from YouTube, Vimeo, Imgur, 9GAG, Cloudinary, Tumblr and Publiti
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.
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.2.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
193
 
194
  == Changelog ==
195
 
196
+ = 3.2.0 =
197
+ * Bug fix: images from some addresses were not being shown; bug fix: URL from Post Content (hide option not working for IFTTT posts).
198
+
199
  = 3.1.9 =
200
  * Improvement: Lazy Load (performance and compatibility); deprecated: URL Parameters; bug fix: Default Featured Image not working for IFTTT posts.
201
 
202
  = 3.1.8 =
203
  * New language: Greek; improvement: readme strings added to the pot file; bug fix: conflict between lazy load and background-image.
204
 
 
 
 
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
+ = 3.2.0 =
212
+ * Bug fix: images from some addresses were not being shown; bug fix: URL from Post Content (hide option not working for IFTTT posts).