Featured Image From URL - Version 3.2.4

Version Description

  • Critical bug fix: conflict with URLs from Jetpack, Cloudinary and maybe others.
Download this release

Release Info

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

Code changes from version 3.2.3 to 3.2.4

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.2.3
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.2.4
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
includes/attachment.php CHANGED
@@ -9,55 +9,28 @@ function fifu_replace_attached_file($att_url, $att_id) {
9
  }
10
 
11
  function fifu_process_url($att_url, $att_id) {
12
- if ($att_url) {
13
- // legacy
14
- $url = explode(";", $att_url);
15
- if (sizeof($url) > 1) {
16
- fifu_fix_legacy($url[1], $att_id);
17
- return fifu_process_external_url($url[1], $att_id);
18
- }
19
 
20
- // full url + external url
21
- preg_match("/^(http[s]*:\/\/|\/\/).*(http[s]*:\/\/|\/\/)/", $att_url, $matches);
22
- if ($matches) {
23
- preg_match_all("/(http[s]*:\/\/|\/\/)/", $att_url, $matches);
24
- $matches = $matches[0];
25
-
26
- if ($matches[0] == $matches[1]) {
27
- $url1 = $matches[0] . explode($matches[0], $att_url)[1];
28
- $url2 = $matches[1] . explode($matches[1], $att_url)[2];
29
- } else {
30
- $url1 = $matches[0] . explode($matches[1], explode($matches[0], $att_url)[1])[0];
31
- $url2 = $matches[1] . explode($matches[1], explode($matches[0], $att_url)[1])[1];
32
- }
33
- return fifu_process_external_url($url2, $att_id);
34
- }
35
 
36
- // relative url + external url
37
- preg_match("/^(\/[^\/]|[.]+[\/]).*(http[s]*:\/\/|\/\/)/", $att_url, $matches);
38
- if ($matches) {
39
- preg_match_all("/(http[s]*:\/\/|\/\/)/", $att_url, $matches);
40
- $matches = $matches[0];
41
- $url = $matches[0] . explode($matches[0], $att_url)[1];
42
- return fifu_process_external_url($url, $att_id);
43
- }
44
 
45
- // string + external url
46
- if (!fifu_starts_with($att_url, 'http') && !fifu_starts_with($att_url, '/')) {
47
- preg_match_all("/(http[s]*:\/\/|\/\/)/", $att_url, $matches);
48
- $url = $matches[0] . explode($matches[0], $att_url)[1];
49
- return fifu_process_external_url($url, $att_id);
50
- }
51
 
52
- // url (internal or external?)
53
- if (fifu_starts_with($att_url, 'http') || fifu_starts_with($att_url, '//'))
54
- return fifu_process_unknow_url($att_url, $att_id);
55
- }
56
- return $att_url;
57
- }
58
 
59
- function fifu_process_unknow_url($url, $att_id) {
60
- return fifu_has_internal_image_path($url) ? $url : fifu_process_external_url($url, $att_id);
 
61
  }
62
 
63
  function fifu_process_external_url($url, $att_id) {
@@ -65,30 +38,19 @@ function fifu_process_external_url($url, $att_id) {
65
  }
66
 
67
  function fifu_fix_legacy($url, $att_id) {
 
 
68
  $att_url = get_post_meta($att_id, '_wp_attached_file');
69
  $att_url = is_array($att_url) ? $att_url[0] : $att_url;
70
- if (fifu_starts_with($att_url, ';http') || fifu_starts_with($att_url, ';//'))
71
  update_post_meta($att_id, '_wp_attached_file', $url);
72
  }
73
 
74
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
75
 
76
  function fifu_replace_attachment_url($att_url, $att_id) {
77
- if ($att_url) {
78
- $url = fifu_process_url($att_url, $att_id);
79
- if ($url)
80
- return $url;
81
- else {
82
- $post = get_post($att_id);
83
- if ($post) {
84
- if ($att_url && strpos($att_url, 'http') === 0 && $post->post_author != FIFU_AUTHOR)
85
- return $att_url;
86
-
87
- if (!fifu_reject_guid())
88
- return get_post($att_id)->guid;
89
- }
90
- }
91
- }
92
  return $att_url;
93
  }
94
 
@@ -113,17 +75,28 @@ add_filter('posts_where', function ($where, \WP_Query $q) {
113
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
114
 
115
  function fifu_replace_attachment_image_src($image, $att_id, $size) {
116
- global $post;
117
-
118
  if (!$image || !$att_id)
119
  return $image;
120
 
121
  $att_post = get_post($att_id);
122
 
123
- $image[0] = fifu_process_url($image[0], $att_id);
 
124
 
125
- if (fifu_has_internal_image_path($image[0]) && $att_post->post_author != FIFU_AUTHOR)
 
 
 
126
  return $image;
 
 
 
 
 
 
 
 
 
127
 
128
  if (fifu_should_hide() && fifu_main_image_url($post->ID) == $image[0])
129
  return null;
@@ -163,27 +136,6 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
163
  );
164
  }
165
 
166
- function fifu_get_internal_image_path() {
167
- return explode("//", get_home_url())[1] . "/wp-content/uploads/";
168
- }
169
-
170
- function fifu_get_internal_image_path2() {
171
- return get_bloginfo() . ".files.wordpress.com";
172
- }
173
-
174
- function fifu_get_internal_image_path3() {
175
- return explode('.', explode("//", get_home_url())[1])[0] . ".files.wordpress.com";
176
- }
177
-
178
- // for WPML Multilingual CMS
179
- function fifu_get_internal_image_path4() {
180
- return explode("/", explode("//", get_home_url())[1])[0] . "/wp-content/uploads/";
181
- }
182
-
183
- function fifu_has_internal_image_path($url) {
184
- return strpos($url, fifu_get_internal_image_path()) !== false || strpos($url, fifu_get_internal_image_path2()) !== false || strpos($url, fifu_get_internal_image_path3()) !== false || strpos($url, fifu_get_internal_image_path4()) !== false;
185
- }
186
-
187
  add_action('template_redirect', 'fifu_action', 10);
188
 
189
  function fifu_action() {
@@ -330,31 +282,3 @@ function fifu_add_url_parameters($url, $att_id) {
330
  return $url;
331
  }
332
 
333
- // plugin: accelerated-mobile-pages
334
-
335
- function fifu_amp_url($url, $width, $height) {
336
- $size = get_post_meta(get_the_ID(), 'fifu_image_dimension');
337
- if (!empty($size)) {
338
- $size = explode(';', $size[0]);
339
- $width = $size[0];
340
- $height = $size[1];
341
- }
342
- return array(0 => $url, 1 => $width, 2 => $height);
343
- }
344
-
345
- function fifu_reject_guid() {
346
- return fifu_is_mpd_active() || fifu_is_classified_listing_active();
347
- }
348
-
349
- // plugin: multisite-post-duplicator
350
-
351
- function fifu_is_mpd_active() {
352
- return is_plugin_active('multisite-post-duplicator/mpd.php');
353
- }
354
-
355
- // plugin: classified-listing
356
-
357
- function fifu_is_classified_listing_active() {
358
- return is_plugin_active('classified-listing/classified-listing.php') || is_plugin_active('classified-listing-pro/classified-listing-pro.php');
359
- }
360
-
9
  }
10
 
11
  function fifu_process_url($att_url, $att_id) {
12
+ if (!$att_id)
13
+ return $att_url;
 
 
 
 
 
14
 
15
+ $att_post = get_post($att_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ if (!$att_post)
18
+ return $att_url;
 
 
 
 
 
 
19
 
20
+ // jetpack
21
+ preg_match("/^http[s]*:\/\/[i][0-9][.]wp.com\//", $att_url, $matches);
22
+ if ($matches)
23
+ return fifu_process_external_url($att_url, $att_id);
 
 
24
 
25
+ // internal
26
+ if ($att_post->post_author != FIFU_AUTHOR)
27
+ return $att_url;
28
+
29
+ $url = $att_post->guid;
 
30
 
31
+ fifu_fix_legacy($url, $att_id);
32
+
33
+ return fifu_process_external_url($url, $att_id);
34
  }
35
 
36
  function fifu_process_external_url($url, $att_id) {
38
  }
39
 
40
  function fifu_fix_legacy($url, $att_id) {
41
+ if (strpos($url, ';') === false)
42
+ return;
43
  $att_url = get_post_meta($att_id, '_wp_attached_file');
44
  $att_url = is_array($att_url) ? $att_url[0] : $att_url;
45
+ if (fifu_starts_with($att_url, ';http') || fifu_starts_with($att_url, ';/'))
46
  update_post_meta($att_id, '_wp_attached_file', $url);
47
  }
48
 
49
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
50
 
51
  function fifu_replace_attachment_url($att_url, $att_id) {
52
+ if ($att_url && !get_option('fifu_get_internal'))
53
+ return fifu_process_url($att_url, $att_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  return $att_url;
55
  }
56
 
75
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
76
 
77
  function fifu_replace_attachment_image_src($image, $att_id, $size) {
 
 
78
  if (!$image || !$att_id)
79
  return $image;
80
 
81
  $att_post = get_post($att_id);
82
 
83
+ if (!$att_post)
84
+ return $image;
85
 
86
+ // jetpack
87
+ preg_match("/^http[s]*:\/\/[i][0-9][.]wp.com\//", $image[0], $matches);
88
+ if ($matches) {
89
+ $image[0] = fifu_process_external_url($image[0], $att_id);
90
  return $image;
91
+ }
92
+
93
+ // internal
94
+ if ($att_post->post_author != FIFU_AUTHOR)
95
+ return $image;
96
+
97
+ $image[0] = fifu_process_url($image[0], $att_id);
98
+
99
+ global $post;
100
 
101
  if (fifu_should_hide() && fifu_main_image_url($post->ID) == $image[0])
102
  return null;
136
  );
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  add_action('template_redirect', 'fifu_action', 10);
140
 
141
  function fifu_action() {
282
  return $url;
283
  }
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
4
  Tags: featured image, featured, image, url, thumbnail
5
  Requires at least: 5.0
6
  Tested up to: 5.5
7
- Stable tag: 3.2.3
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.2.3 =
197
  * Improvement: core changes for a better integration with themes, plugins and WordPress 5.5; bug fix: conflict between Hide Featured Media and Related Posts Thumbnails plugin.
198
 
199
  = 3.2.2 =
200
  * Adjustment: layout changes for WordPress 5.5; improvement: Flickr Thumbnails (less controls and more precision); bug fix: conflict between Lazy Load and Avada theme.
201
 
202
- = 3.2.1 =
203
- * New: performance tips; bug fix: images from some addresses were not being shown.
204
-
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
- = 3.2.3 =
212
- * Improvement: core changes for a better integration with themes, plugins and WordPress 5.5; bug fix: conflict between Hide Featured Media and Related Posts Thumbnails plugin.
4
  Tags: featured image, featured, image, url, thumbnail
5
  Requires at least: 5.0
6
  Tested up to: 5.5
7
+ Stable tag: 3.2.4
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
193
 
194
  == Changelog ==
195
 
196
+ = 3.2.4 =
197
+ * Critical bug fix: conflict with URLs from Jetpack, Cloudinary and maybe others.
198
+
199
  = 3.2.3 =
200
  * Improvement: core changes for a better integration with themes, plugins and WordPress 5.5; bug fix: conflict between Hide Featured Media and Related Posts Thumbnails plugin.
201
 
202
  = 3.2.2 =
203
  * Adjustment: layout changes for WordPress 5.5; improvement: Flickr Thumbnails (less controls and more precision); bug fix: conflict between Lazy Load and Avada theme.
204
 
 
 
 
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
+ = 3.2.4 =
212
+ * Critical bug fix: conflict with URLs from Jetpack, Cloudinary and maybe others.