Featured Image From URL - Version 3.2.3

Version Description

  • 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.
Download this release

Release Info

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

Code changes from version 3.2.2 to 3.2.3

admin/api.php CHANGED
@@ -108,7 +108,8 @@ add_action('rest_api_init', function () {
108
  ));
109
  register_rest_route('featured-image-from-url/v2', '/rest_url_api/', array(
110
  'methods' => ['GET', 'POST'],
111
- 'callback' => 'fifu_rest_url'
 
112
  ));
113
  });
114
 
@@ -119,3 +120,7 @@ function fifu_get_private_data_permissions_check() {
119
  return true;
120
  }
121
 
 
 
 
 
108
  ));
109
  register_rest_route('featured-image-from-url/v2', '/rest_url_api/', array(
110
  'methods' => ['GET', 'POST'],
111
+ 'callback' => 'fifu_rest_url',
112
+ 'permission_callback' => 'fifu_public_permission',
113
  ));
114
  });
115
 
120
  return true;
121
  }
122
 
123
+ function fifu_public_permission() {
124
+ return true;
125
+ }
126
+
admin/db.php CHANGED
@@ -46,7 +46,7 @@ class FifuDb {
46
  function insert_attachment_meta_url($ids) {
47
  $this->wpdb->get_results("
48
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
49
- SELECT p.id, '_wp_attached_file', CONCAT(';', p.guid)
50
  FROM " . $this->posts . " p
51
  WHERE p.post_parent IN (" . $ids . ")
52
  AND p.post_type = 'attachment'
@@ -709,7 +709,7 @@ class FifuDb {
709
  // update
710
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
711
  if ($has_fifu_attachment) {
712
- update_post_meta($att_id, '_wp_attached_file', ';' . $url);
713
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
714
  $this->wpdb->update($this->posts, $set = array('post_title' => $alt, 'guid' => $url), $where = array('id' => $att_id), null, null);
715
  }
@@ -719,7 +719,7 @@ class FifuDb {
719
  $this->insert_attachment_by($value);
720
  $att_id = $this->wpdb->insert_id;
721
  update_post_meta($post_id, '_thumbnail_id', $att_id);
722
- update_post_meta($att_id, '_wp_attached_file', ';' . $url);
723
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
724
  $attachments = $this->get_attachments_without_post($post_id);
725
  if ($attachments) {
@@ -751,7 +751,7 @@ class FifuDb {
751
  // update
752
  $alt = get_term_meta($term_id, 'fifu_image_alt', true);
753
  if ($has_fifu_attachment) {
754
- update_post_meta($att_id, '_wp_attached_file', ';' . $url);
755
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
756
  $this->wpdb->update($this->posts, $set = array('guid' => $url, 'post_title' => $alt), $where = array('id' => $att_id), null, null);
757
  }
@@ -761,7 +761,7 @@ class FifuDb {
761
  $this->insert_attachment_by($value);
762
  $att_id = $this->wpdb->insert_id;
763
  update_term_meta($term_id, 'thumbnail_id', $att_id);
764
- update_post_meta($att_id, '_wp_attached_file', ';' . $url);
765
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
766
  $attachments = $this->get_ctgr_attachments_without_post($term_id);
767
  if ($attachments) {
@@ -791,7 +791,7 @@ class FifuDb {
791
  }
792
  if ($value) {
793
  $this->insert_default_thumbnail_id($value);
794
- update_post_meta($att_id, '_wp_attached_file', ';' . get_option('fifu_default_url'));
795
  }
796
  }
797
 
@@ -799,7 +799,7 @@ class FifuDb {
799
  $att_id = get_option('fifu_default_attach_id');
800
  if ($url != wp_get_attachment_url($att_id)) {
801
  $this->wpdb->update($this->posts, $set = array('guid' => $url), $where = array('id' => $att_id), null, null);
802
- update_post_meta($att_id, '_wp_attached_file', ';' . $url);
803
  }
804
  }
805
 
46
  function insert_attachment_meta_url($ids) {
47
  $this->wpdb->get_results("
48
  INSERT INTO " . $this->postmeta . " (post_id, meta_key, meta_value) (
49
+ SELECT p.id, '_wp_attached_file', p.guid
50
  FROM " . $this->posts . " p
51
  WHERE p.post_parent IN (" . $ids . ")
52
  AND p.post_type = 'attachment'
709
  // update
710
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
711
  if ($has_fifu_attachment) {
712
+ update_post_meta($att_id, '_wp_attached_file', $url);
713
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
714
  $this->wpdb->update($this->posts, $set = array('post_title' => $alt, 'guid' => $url), $where = array('id' => $att_id), null, null);
715
  }
719
  $this->insert_attachment_by($value);
720
  $att_id = $this->wpdb->insert_id;
721
  update_post_meta($post_id, '_thumbnail_id', $att_id);
722
+ update_post_meta($att_id, '_wp_attached_file', $url);
723
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
724
  $attachments = $this->get_attachments_without_post($post_id);
725
  if ($attachments) {
751
  // update
752
  $alt = get_term_meta($term_id, 'fifu_image_alt', true);
753
  if ($has_fifu_attachment) {
754
+ update_post_meta($att_id, '_wp_attached_file', $url);
755
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
756
  $this->wpdb->update($this->posts, $set = array('guid' => $url, 'post_title' => $alt), $where = array('id' => $att_id), null, null);
757
  }
761
  $this->insert_attachment_by($value);
762
  $att_id = $this->wpdb->insert_id;
763
  update_term_meta($term_id, 'thumbnail_id', $att_id);
764
+ update_post_meta($att_id, '_wp_attached_file', $url);
765
  update_post_meta($att_id, '_wp_attachment_image_alt', $alt);
766
  $attachments = $this->get_ctgr_attachments_without_post($term_id);
767
  if ($attachments) {
791
  }
792
  if ($value) {
793
  $this->insert_default_thumbnail_id($value);
794
+ update_post_meta($att_id, '_wp_attached_file', get_option('fifu_default_url'));
795
  }
796
  }
797
 
799
  $att_id = get_option('fifu_default_attach_id');
800
  if ($url != wp_get_attachment_url($att_id)) {
801
  $this->wpdb->update($this->posts, $set = array('guid' => $url), $where = array('id' => $att_id), null, null);
802
+ update_post_meta($att_id, '_wp_attached_file', $url);
803
  }
804
  }
805
 
admin/html/category.html CHANGED
@@ -3,7 +3,7 @@
3
  <tr>
4
  <td>
5
  <span class="dashicons dashicons-camera" style="font-size:20px"></span>
6
- <?php esc_html_e('Featured Image (URL)', 'featured-image-from-url'); ?>
7
  </td>
8
  <td>
9
  <div class="box">
3
  <tr>
4
  <td>
5
  <span class="dashicons dashicons-camera" style="font-size:20px"></span>
6
+ <?php esc_html_e('Featured image', 'featured-image-from-url'); ?>
7
  </td>
8
  <td>
9
  <div class="box">
admin/html/js/meta-box.js CHANGED
@@ -59,6 +59,7 @@ function runPreview($url) {
59
  if ($url) {
60
  jQuery("#fifu_button").hide();
61
  jQuery("#fifu_help").hide();
 
62
 
63
  jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
64
 
@@ -94,6 +95,13 @@ jQuery(document).ready(function () {
94
  jQuery.fancybox.open('<img src="' + jQuery("#fifu_input_url").val() + '" style="max-height:600px">');
95
  });
96
 
 
 
 
 
 
 
 
97
  jQuery("div#imageUrlMetaBox").find('h2').replaceWith('<h3 style="top:7px;position:relative;"><span class="dashicons dashicons-camera" style="font-size:15px"></span> Featured image</h3>');
98
  jQuery("div#urlMetaBox").find('h2').replaceWith('<h4 style="top:5px;position:relative;"><span class="dashicons dashicons-camera" style="font-size:15px"></span> Product image</h4>');
99
  });
59
  if ($url) {
60
  jQuery("#fifu_button").hide();
61
  jQuery("#fifu_help").hide();
62
+ jQuery("#fifu_premium").hide();
63
 
64
  jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
65
 
95
  jQuery.fancybox.open('<img src="' + jQuery("#fifu_input_url").val() + '" style="max-height:600px">');
96
  });
97
 
98
+ jQuery('.fifu-hover').on('mouseover', function (evt) {
99
+ jQuery(this).css('color', '#23282e');
100
+ });
101
+ jQuery('.fifu-hover').on('mouseout', function (evt) {
102
+ jQuery(this).css('color', 'white');
103
+ });
104
+
105
  jQuery("div#imageUrlMetaBox").find('h2').replaceWith('<h3 style="top:7px;position:relative;"><span class="dashicons dashicons-camera" style="font-size:15px"></span> Featured image</h3>');
106
  jQuery("div#urlMetaBox").find('h2').replaceWith('<h4 style="top:5px;position:relative;"><span class="dashicons dashicons-camera" style="font-size:15px"></span> Product image</h4>');
107
  });
admin/html/menu.html CHANGED
@@ -567,6 +567,27 @@
567
  </div>
568
  </div>
569
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570
  <div class="box">
571
  <div class="fifu-pro">premium</div>
572
  <h2><?php esc_html_e('Unsplash Image Size', 'featured-image-from-url'); ?></h2>
567
  </div>
568
  </div>
569
 
570
+ <div class="box">
571
+ <div class="fifu-pro">premium</div>
572
+ <h2><?php esc_html_e('Giphy Search', 'featured-image-from-url'); ?></h2>
573
+ <div class="greybox" id="grad2">
574
+ <?php esc_html_e('Enable keyword gif search at featured image box.', 'featured-image-from-url'); ?>
575
+ </div>
576
+ <br>
577
+ <table style="text-align:left">
578
+ <tr>
579
+ <th>
580
+ <input
581
+ type="submit"
582
+ href="javascript:void(0)"
583
+ class="toggleoff"
584
+ value=""
585
+ style="display:block;border:none">
586
+ </th>
587
+ </tr>
588
+ </table>
589
+ </div>
590
+
591
  <div class="box">
592
  <div class="fifu-pro">premium</div>
593
  <h2><?php esc_html_e('Unsplash Image Size', 'featured-image-from-url'); ?></h2>
admin/html/meta-box-shortcode.html DELETED
@@ -1,8 +0,0 @@
1
- <input
2
- id="fifu_shortcode_input"
3
- type="text"
4
- name="fifu_shortcode_input"
5
- value=""
6
- style="<?php echo $width?>;font-size:13px;"
7
- disabled
8
- placeholder="[ <?php esc_html_e('Shortcode') ?> ] (Premium)"/>
 
 
 
 
 
 
 
 
admin/html/meta-box-slider.html DELETED
@@ -1,7 +0,0 @@
1
- <input id="fifu_slider_input_url_<?php echo $i; ?>"
2
- type="text"
3
- name="fifu_slider_input_url_<?php echo $i; ?>"
4
- placeholder="<?php esc_html_e('Image URL') ?> (Premium)"
5
- value=""
6
- disabled
7
- style="<?php echo $width ?>;font-size:13px;" />
 
 
 
 
 
 
 
admin/html/meta-box-video.html DELETED
@@ -1,7 +0,0 @@
1
- <input id="fifu_video_input_url"
2
- type="text"
3
- name="fifu_video_input_url"
4
- placeholder="<?php esc_html_e('Video URL', 'featured-image-from-url') ?> (Premium)"
5
- value=""
6
- disabled
7
- style="<?php echo $width, $margin ?>;font-size:13px;" />
 
 
 
 
 
 
 
admin/html/meta-box.html CHANGED
@@ -39,7 +39,7 @@
39
  </td>
40
  <td>
41
  <span id="fifu_help"
42
- title="<?php esc_html_e('Examples: image URL: https://domain.com/image.jpg; keywords: sea,sun. To get a random image leave this field empty.', 'featured-image-from-url'); ?>"
43
  class="dashicons dashicons-editor-help"
44
  style="<?php echo $show_button . ';font-size:20px' ?>">
45
  </span>
@@ -95,4 +95,17 @@
95
  title="<?php esc_html_e('Add image from Sirv', 'featured-image-from-url'); ?>"><?php esc_html_e('Choose Sirv image', 'featured-image-from-url'); ?></a>
96
  </div>
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  </div>
39
  </td>
40
  <td>
41
  <span id="fifu_help"
42
+ title="<?php esc_html_e('Examples: https://domain.com/image.jpg (image URL); sea,sun (keywords); empty (random image)', 'featured-image-from-url'); ?>"
43
  class="dashicons dashicons-editor-help"
44
  style="<?php echo $show_button . ';font-size:20px' ?>">
45
  </span>
95
  title="<?php esc_html_e('Add image from Sirv', 'featured-image-from-url'); ?>"><?php esc_html_e('Choose Sirv image', 'featured-image-from-url'); ?></a>
96
  </div>
97
 
98
+ <div id="fifu_premium" style="<?php echo $show_button ?>">
99
+ <table style="position: relative; top: 12px; background-color: #007cba; color:white; width: 100%; border-radius: 3px">
100
+ <tr style="text-align: center;">
101
+ <td style="width: 90px; font-size: 9px"><a style="color:white; text-decoration: none" target="_blank" href="https://fifu.app/">Premium fields</a></td>
102
+ <td class="fifu-hover"><span title="Featured video" class="dashicons dashicons-video-alt3" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
103
+ <td class="fifu-hover"><span title="Woocommerce image gallery" class="dashicons dashicons-format-gallery" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
104
+ <td class="fifu-hover"><span title="Woocommerce video gallery" class="dashicons dashicons-format-video" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
105
+ <td class="fifu-hover"><span title="Featured slider" class="dashicons dashicons-images-alt2" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
106
+ <td class="fifu-hover"><span title="Featured shortcode" class="dashicons dashicons-editor-code" style="font-size:13px; display: unset; vertical-align:sub;"></span></td>
107
+ </tr>
108
+ </table>
109
+ </div>
110
+
111
  </div>
admin/html/woo-meta-box-video.html DELETED
@@ -1,7 +0,0 @@
1
- <input id="fifu_video_input_url_<?php echo $i; ?>"
2
- type="text"
3
- name="fifu_video_input_url_<?php echo $i; ?>"
4
- placeholder="<?php esc_html_e('Video URL', 'featured-image-from-url') ?> (Premium)"
5
- value=""
6
- disabled
7
- style="<?php echo $width ?>;font-size:13px;" />
 
 
 
 
 
 
 
admin/html/woo-meta-box.html DELETED
@@ -1,7 +0,0 @@
1
- <input id="fifu_input_url_<?php echo $i; ?>"
2
- type="text"
3
- name="fifu_input_url_<?php echo $i; ?>"
4
- placeholder="<?php esc_html_e('Image URL') ?> (Premium)"
5
- value=""
6
- disabled
7
- style="<?php echo $width, $margin?>;font-size:13px;" />
 
 
 
 
 
 
 
admin/meta-box.php CHANGED
@@ -63,47 +63,6 @@ function fifu_show_elements($post) {
63
  include 'html/meta-box.html';
64
  }
65
 
66
- function fifu_shortcode_show_elements($post) {
67
- $width = 'width:100%;';
68
- $align = 'text-align:left;';
69
- include 'html/meta-box-shortcode.html';
70
- }
71
-
72
- function fifu_video_show_elements($post) {
73
- $margin = 'margin-top:10px;';
74
- $width = 'width:100%;';
75
- $height = 'height:150px;';
76
- $align = 'text-align:left;';
77
- include 'html/meta-box-video.html';
78
- }
79
-
80
- function fifu_wc_show_elements($post) {
81
- $margin = 'margin-top:1px;';
82
- $width = 'width:100%;';
83
- $height = 'height:150px;';
84
- $align = 'text-align:left;';
85
- for ($i = 0; $i < 3; $i++)
86
- include 'html/woo-meta-box.html';
87
- }
88
-
89
- function fifu_video_wc_show_elements($post) {
90
- $margin = 'margin-top:1px;';
91
- $width = 'width:100%;';
92
- $height = 'height:150px;';
93
- $align = 'text-align:left;';
94
- for ($i = 0; $i < 3; $i++)
95
- include 'html/woo-meta-box-video.html';
96
- }
97
-
98
- function fifu_slider_show_elements($post) {
99
- $margin = 'margin-top:1px;';
100
- $width = 'width:100%;';
101
- $height = 'height:150px;';
102
- $align = 'text-align:left;';
103
- for ($i = 0; $i < 3; $i++)
104
- include 'html/meta-box-slider.html';
105
- }
106
-
107
  add_filter('wp_insert_post_data', 'fifu_remove_first_image', 10, 2);
108
 
109
  function fifu_remove_first_image($data, $postarr) {
63
  include 'html/meta-box.html';
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  add_filter('wp_insert_post_data', 'fifu_remove_first_image', 10, 2);
67
 
68
  function fifu_remove_first_image($data, $postarr) {
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.2
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.3
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 3.0
includes/attachment.php CHANGED
@@ -1,28 +1,87 @@
1
  <?php
2
 
 
 
3
  add_filter('get_attached_file', 'fifu_replace_attached_file', 10, 2);
4
 
5
  function fifu_replace_attached_file($att_url, $att_id) {
 
 
 
 
6
  if ($att_url) {
 
7
  $url = explode(";", $att_url);
8
- if (sizeof($url) > 1)
9
- return fifu_has_internal_image_path($url[1]) ? get_post($att_id)->guid : $url[1];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
  return $att_url;
12
  }
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
15
 
16
  function fifu_replace_attachment_url($att_url, $att_id) {
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);
24
  if ($post) {
25
- if ($att_url && strpos($att_url, 'http') === 0 && $post->post_author != "77777")
26
  return $att_url;
27
 
28
  if (!fifu_reject_guid())
@@ -38,7 +97,7 @@ add_filter('posts_where', 'fifu_query_attachments');
38
  function fifu_query_attachments($where) {
39
  if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments') && fifu_is_off('fifu_media_library')) {
40
  global $wpdb;
41
- $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> 77777 ';
42
  }
43
  return $where;
44
  }
@@ -46,7 +105,7 @@ function fifu_query_attachments($where) {
46
  add_filter('posts_where', function ($where, \WP_Query $q) {
47
  if (is_admin() && $q->is_main_query() && fifu_is_off('fifu_media_library')) {
48
  global $wpdb;
49
- $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> 77777 ';
50
  }
51
  return $where;
52
  }, 10, 2);
@@ -54,32 +113,32 @@ add_filter('posts_where', function ($where, \WP_Query $q) {
54
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
55
 
56
  function fifu_replace_attachment_image_src($image, $att_id, $size) {
57
- if (!$image)
58
- return $image;
59
-
60
- if (strpos($image[0], ';http') !== false)
61
- $image[0] = 'http' . explode(";http", $image[0])[1];
62
 
63
- if (!$att_id)
64
  return $image;
65
 
66
- $post = get_post($att_id);
67
 
68
- if (fifu_has_internal_image_path($image[0]) && $post->post_author != "77777")
 
 
69
  return $image;
70
 
71
- if (fifu_should_hide())
72
  return null;
 
73
  $image_size = fifu_get_image_size($size);
74
  if (fifu_is_on('fifu_original')) {
75
  return array(
76
- fifu_has_internal_image_path($image[0]) ? get_post($att_id)->guid : $image[0],
77
  null,
78
  null,
79
  null,
80
  );
81
  }
82
- $dimension = $post ? get_post_meta($post->ID, 'fifu_image_dimension') : null;
 
83
  $arrFIFU = fifu_get_width_height($dimension);
84
 
85
  $width = $arrFIFU['width'];
@@ -97,7 +156,7 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
97
  }
98
 
99
  return array(
100
- fifu_has_internal_image_path($image[0]) ? get_post($att_id)->guid : $image[0],
101
  $width,
102
  $height,
103
  isset($image_size['crop']) ? $image_size['crop'] : '',
1
  <?php
2
 
3
+ define('FIFU_AUTHOR', 77777);
4
+
5
  add_filter('get_attached_file', 'fifu_replace_attached_file', 10, 2);
6
 
7
  function fifu_replace_attached_file($att_url, $att_id) {
8
+ return fifu_process_url($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) {
64
+ return fifu_add_url_parameters($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())
97
  function fifu_query_attachments($where) {
98
  if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments') && fifu_is_off('fifu_media_library')) {
99
  global $wpdb;
100
+ $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
101
  }
102
  return $where;
103
  }
105
  add_filter('posts_where', function ($where, \WP_Query $q) {
106
  if (is_admin() && $q->is_main_query() && fifu_is_off('fifu_media_library')) {
107
  global $wpdb;
108
+ $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' ';
109
  }
110
  return $where;
111
  }, 10, 2);
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;
130
+
131
  $image_size = fifu_get_image_size($size);
132
  if (fifu_is_on('fifu_original')) {
133
  return array(
134
+ $image[0],
135
  null,
136
  null,
137
  null,
138
  );
139
  }
140
+
141
+ $dimension = $att_post ? get_post_meta($att_post->ID, 'fifu_image_dimension') : null;
142
  $arrFIFU = fifu_get_width_height($dimension);
143
 
144
  $width = $arrFIFU['width'];
156
  }
157
 
158
  return array(
159
+ $image[0],
160
  $width,
161
  $height,
162
  isset($image_size['crop']) ? $image_size['crop'] : '',
includes/util.php CHANGED
@@ -72,6 +72,10 @@ function fifu_normalize($tag) {
72
  return $tag;
73
  }
74
 
 
 
 
 
75
  /* dimensions */
76
 
77
  function fifu_curl($url) {
72
  return $tag;
73
  }
74
 
75
+ function fifu_starts_with($text, $substr) {
76
+ return substr($text, 0, strlen($substr)) === $substr;
77
+ }
78
+
79
  /* dimensions */
80
 
81
  function fifu_curl($url) {
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  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.5
7
- Stable tag: 3.2.2
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.2 =
197
  * Adjustment: layout changes for WordPress 5.5; improvement: Flickr Thumbnails (less controls and more precision); bug fix: conflict between Lazy Load and Avada theme.
198
 
199
  = 3.2.1 =
200
  * New: performance tips; bug fix: images from some addresses were not being shown.
201
 
202
- = 3.2.0 =
203
- * Bug fix: images from some addresses were not being shown; bug fix: URL from Post Content (hide option not working for IFTTT posts).
204
-
205
  = others =
206
  * [more](https://fifu.app/changelog/)
207
 
208
 
209
  == Upgrade Notice ==
210
 
211
- = 3.2.2 =
212
- * Adjustment: layout changes for WordPress 5.5; improvement: Flickr Thumbnails (less controls and more precision); bug fix: conflict between Lazy Load and Avada theme.
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  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
 
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.