Featured Image From URL - Version 1.6.0

Version Description

  • WP REST API.

=

Download this release

Release Info

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

Code changes from version 1.5.9 to 1.6.0

admin/html/category.html CHANGED
@@ -1,12 +1,12 @@
1
  <style><?php include 'css/category.css' ?></style>
2
 
3
  <tr>
4
- <th>Featured Image from URL</th>
5
- <td>
6
- <div class="box">
7
- <?php include 'meta-box.html' ?>
8
- </div>
9
- </td>
10
  </tr>
11
 
12
  <br/>
1
  <style><?php include 'css/category.css' ?></style>
2
 
3
  <tr>
4
+ <th>Featured Image from URL</th>
5
+ <td>
6
+ <div class="box">
7
+ <?php include 'meta-box.html' ?>
8
+ </div>
9
+ </td>
10
  </tr>
11
 
12
  <br/>
admin/html/css/category.css CHANGED
@@ -1,20 +1,20 @@
1
  .box {
2
- margin: 20px 0 0;
3
- background: #fff;
4
- border: 1px solid #dbdbdb;
5
- padding: 20px;
6
- width: 92%;
7
  }
8
 
9
  .greybox {
10
- margin: 10px 0 0;
11
- background: #f9f9f9;
12
- border: 1px solid #dbdbdb;
13
- padding: 20px;
14
  }
15
 
16
  .greybox p {
17
- font-style: italic;
18
- color: #999;
19
  }
20
 
1
  .box {
2
+ margin: 20px 0 0;
3
+ background: #fff;
4
+ border: 1px solid #dbdbdb;
5
+ padding: 20px;
6
+ width: 92%;
7
  }
8
 
9
  .greybox {
10
+ margin: 10px 0 0;
11
+ background: #f9f9f9;
12
+ border: 1px solid #dbdbdb;
13
+ padding: 20px;
14
  }
15
 
16
  .greybox p {
17
+ font-style: italic;
18
+ color: #999;
19
  }
20
 
admin/html/css/menu.css CHANGED
@@ -47,3 +47,11 @@
47
  border-style: solid;
48
  }
49
 
 
 
 
 
 
 
 
 
47
  border-style: solid;
48
  }
49
 
50
+ th, td {
51
+ border-bottom: 1px solid #ddd;
52
+ padding-right: 32px;
53
+ }
54
+
55
+ th {
56
+ height: 25px;
57
+ }
admin/html/js/category.js CHANGED
@@ -1,26 +1,26 @@
1
  function removeImage() {
2
- jQuery("#fifu_input_alt").hide();
3
- jQuery("#fifu_image").hide();
4
- jQuery("#fifu_link").hide();
5
 
6
- jQuery("#fifu_input_alt").val("");
7
- jQuery("#fifu_input_url").val("");
8
 
9
- jQuery("#fifu_input_url").show();
10
- jQuery("#fifu_button").show();
11
  }
12
 
13
  function previewImage() {
14
- var $url = jQuery("#fifu_input_url").val();
15
 
16
- if ($url) {
17
- jQuery("#fifu_input_url").hide();
18
- jQuery("#fifu_button").hide();
19
 
20
- jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
21
 
22
- jQuery("#fifu_input_alt").show();
23
- jQuery("#fifu_image").show();
24
- jQuery("#fifu_link").show();
25
- }
26
  }
1
  function removeImage() {
2
+ jQuery("#fifu_input_alt").hide();
3
+ jQuery("#fifu_image").hide();
4
+ jQuery("#fifu_link").hide();
5
 
6
+ jQuery("#fifu_input_alt").val("");
7
+ jQuery("#fifu_input_url").val("");
8
 
9
+ jQuery("#fifu_input_url").show();
10
+ jQuery("#fifu_button").show();
11
  }
12
 
13
  function previewImage() {
14
+ var $url = jQuery("#fifu_input_url").val();
15
 
16
+ if ($url) {
17
+ jQuery("#fifu_input_url").hide();
18
+ jQuery("#fifu_button").hide();
19
 
20
+ jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
21
 
22
+ jQuery("#fifu_input_alt").show();
23
+ jQuery("#fifu_image").show();
24
+ jQuery("#fifu_link").show();
25
+ }
26
  }
admin/html/js/menu.js CHANGED
@@ -26,6 +26,7 @@ jQuery(function () {
26
  jQuery("#fifu_input_spinner_slider").spinner({min: 0});
27
  jQuery("#fifu_input_slider_speed").spinner({min: 0});
28
  jQuery("#fifu_input_slider_pause").spinner({min: 0});
 
29
  });
30
 
31
  function save(formName, url) {
26
  jQuery("#fifu_input_spinner_slider").spinner({min: 0});
27
  jQuery("#fifu_input_slider_speed").spinner({min: 0});
28
  jQuery("#fifu_input_slider_pause").spinner({min: 0});
29
+ jQuery("#tabsApi").tabs();
30
  });
31
 
32
  function save(formName, url) {
admin/html/menu.html CHANGED
@@ -8,6 +8,13 @@
8
  <h1>Featured Image From URL</h1>
9
  </div>
10
 
 
 
 
 
 
 
 
11
  <div class="box">
12
 
13
  <h2>Auto Set Featured Image</h2>
@@ -881,16 +888,196 @@
881
  </div>
882
 
883
  <div class="box">
884
- <h2>Help</h2>
885
- <div class="greybox">
886
- Featured Image From URL plugin allows you to use an external image (from anywhere) as Featured Image of your Post, Page or Custom Post Type, such as WooCommerce Product. For WooCommerce users, it's also possible to use external images in the Product Category and Product Gallery. All included content still has social tags to facilitate sharing on social networks. And it's compatible with WP All Import plugin using the custom field "fifu_image_url". For more information, refer to <a href="https://wordpress.org/plugins/featured-image-from-url/faq/" target="_blank">FAQ</a> and <a href="https://wordpress.org/plugins/featured-image-from-url/screenshots/" target="_blank">screenshots</a>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
887
  </div>
 
888
  </div>
889
 
890
  <div class="box">
891
- <h2>Give This Plugin a 5-Star Rating</h2>
892
  <div class="greybox">
893
- Do you really love Featured Image From URL? So give this plugin a 5-star <a href="https://wordpress.org/support/view/plugin-reviews/featured-image-from-url?filter=5" target="_blank">rating</a>.
894
  </div>
895
  </div>
896
 
@@ -909,7 +1096,7 @@
909
  <h3>1) "How to get support?"</h3>
910
  You can inform any problem related to the Premium version in the email above. It will be solved as soon as possible and without any cost.<br><br>
911
  <h3>2) "Which plugins are compatible with Premium version?"</h3>
912
- WooCommerce, WP All Import, Monarch, AccessPress Anonymous Post and others. If you intend to use the Premium version with a specific plugin, you can ask me if they are compatible.<br><br>
913
  <h3>3) "Can I get my money back later?"</h3>
914
  With the exception of rare situations, no. But don't worry about that. You will still have the best support and if, after your complete cooperation, I'm not able to solve your issue, I may refund you.<br><br>
915
  <h3>4) "How to get the Premium version?"</h3>
@@ -922,7 +1109,7 @@
922
  </form>
923
  </div>
924
  <div style="display:inline-block;top:-20px;position:relative">
925
- (US$ 25 or more, please) and receive the Premium version by email within 12 hours.
926
  </div>
927
  </div>
928
  </div>
@@ -933,4 +1120,4 @@
933
  Hi! I'm Marcel Jacques Machado. Graduated in Computer Science, I work as a Software Engineer for 10 years. I already worked with C, Python, Shell Script and other programming languages and technologies. Nowadays, I develop web applications in Brazil using Java. About PHP, this plugin, Featured Image From URL, has been a great pratical experience.
934
  </div>
935
  </div>
936
- </div>
8
  <h1>Featured Image From URL</h1>
9
  </div>
10
 
11
+ <div class="box">
12
+ <h2>Give this plugin a <a href="https://wordpress.org/support/view/plugin-reviews/featured-image-from-url?filter=5" target="_blank">5-star</a> rating, please =)</h2>
13
+ <div class="greybox" style="background:#c5c6f9">
14
+ <div style="color:#0073aa">Reaching 100 positive reviews, </div> the "CSS Style" feature will be released for all users.
15
+ </div>
16
+ </div>
17
+
18
  <div class="box">
19
 
20
  <h2>Auto Set Featured Image</h2>
888
  </div>
889
 
890
  <div class="box">
891
+
892
+ <h2>WP REST API</h2>
893
+
894
+ <div class="greybox" style="background:#ffe2e2">
895
+ <b>Premium feature</b><br><br>
896
+ <div id="tabsApi">
897
+ <ul>
898
+ <li><a href="#tabs-1">Endpoints</a></li>
899
+ <li><a href="#tabs-2">Plugin Fields</a></li>
900
+ <li><a href="#tabs-3">Creating your first product...</a></li>
901
+ <li><a href="#tabs-4">Creating your first post...</a></li>
902
+ </ul>
903
+ <div id="tabs-1">
904
+ <table style="text-align:left">
905
+ <tr>
906
+ <th>
907
+ </th>
908
+ <th>
909
+ GET/POST
910
+ </th>
911
+ </tr>
912
+ <tr>
913
+ <th>Shop</th>
914
+ <th>
915
+ <p>http://yourdomain.com/wp-json/wc/v2/products</p>
916
+ </th>
917
+ </tr>
918
+ <tr>
919
+ <th>Blog</th>
920
+ <th>
921
+ <p>http://yourdomain.com/wp-json/wp/v2/posts</p>
922
+ </th>
923
+ </tr>
924
+ </table>
925
+ <br>
926
+ <br>
927
+ <table style="text-align:left">
928
+ <tr>
929
+ <th>
930
+ </th>
931
+ <th>
932
+ GET/PUT/DELETE
933
+ </th>
934
+ </tr>
935
+ <tr>
936
+ <th>Shop</th>
937
+ <th>
938
+ <p>http://yourdomain.com/wp-json/wc/v2/products/{id}</p>
939
+ </th>
940
+ </tr>
941
+ <tr>
942
+ <th>Blog</th>
943
+ <th>
944
+ <p>http://yourdomain.com/wp-json/wp/v2/posts/{id}</p>
945
+ </th>
946
+ </tr>
947
+ </table>
948
+ </div>
949
+
950
+ <div id="tabs-2">
951
+ <table style="text-align:left">
952
+ <tr>
953
+ <th>
954
+ <th>
955
+ Key
956
+ </th>
957
+ <th>
958
+ Key
959
+ </th>
960
+ <th>
961
+ Key
962
+ </th>
963
+ </tr>
964
+ <tr>
965
+ <th>
966
+ Image
967
+ </th>
968
+ <th>
969
+ <p>
970
+ fifu_image_url
971
+ </p>
972
+ </th>
973
+ </tr>
974
+ <tr>
975
+ <th>
976
+ Alt
977
+ </th>
978
+ <th>
979
+ <p>
980
+ fifu_image_alt
981
+ </p>
982
+ </th>
983
+ </tr>
984
+ <tr>
985
+ <th>
986
+ Video
987
+ </th>
988
+ <th>
989
+ <p>
990
+ fifu_video_url
991
+ </p>
992
+ </th>
993
+ </tr>
994
+ <tr>
995
+ <th>
996
+ Image Gallery
997
+ </th>
998
+ <th>
999
+ <p>
1000
+ fifu_image_url_0
1001
+ </p>
1002
+ </th>
1003
+ <th>
1004
+ <p>
1005
+ fifu_image_url_1
1006
+ </p>
1007
+ </th>
1008
+ <th>
1009
+ <p>
1010
+ ...
1011
+ </p>
1012
+ </th>
1013
+ </tr>
1014
+ <tr>
1015
+ <th>
1016
+ Video Gallery
1017
+ </th>
1018
+ <th>
1019
+ <p>
1020
+ fifu_video_url_0
1021
+ </p>
1022
+ </th>
1023
+ <th>
1024
+ <p>
1025
+ fifu_video_url_1
1026
+ </p>
1027
+ </th>
1028
+ <th>
1029
+ <p>
1030
+ ...
1031
+ </p>
1032
+ </th>
1033
+ </tr>
1034
+ <tr>
1035
+ <th>
1036
+ Slider
1037
+ </th>
1038
+ <th>
1039
+ <p>
1040
+ fifu_slider_image_url_0
1041
+ </p>
1042
+ </th>
1043
+ <th>
1044
+ <p>
1045
+ fifu_slider_image_url_1
1046
+ </p>
1047
+ </th>
1048
+ <th>
1049
+ <p>
1050
+ ...
1051
+ </p>
1052
+ </th>
1053
+ </tr>
1054
+ </table>
1055
+ </div>
1056
+
1057
+ <div id="tabs-3">
1058
+ <p>
1059
+ <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/product.txt"
1060
+ width="800px" height="220px" ></iframe>
1061
+ </p>
1062
+ </div>
1063
+
1064
+ <div id="tabs-4">
1065
+ <p>
1066
+ <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/post.txt"
1067
+ width="800px" height="220px" ></iframe>
1068
+ </p>
1069
+ </div>
1070
+
1071
+ </div>
1072
+
1073
  </div>
1074
+
1075
  </div>
1076
 
1077
  <div class="box">
1078
+ <h2>Help</h2>
1079
  <div class="greybox">
1080
+ Featured Image From URL plugin allows you to use an external image (from anywhere) as Featured Image of your Post, Page or Custom Post Type, such as WooCommerce Product. For WooCommerce users, it's also possible to use external images in the Product Category and Product Gallery. All included content still has social tags to facilitate sharing on social networks. And it's compatible with WP All Import plugin using the custom field "fifu_image_url". For more information, refer to <a href="https://wordpress.org/plugins/featured-image-from-url/faq/" target="_blank">FAQ</a> and <a href="https://wordpress.org/plugins/featured-image-from-url/screenshots/" target="_blank">screenshots</a>.
1081
  </div>
1082
  </div>
1083
 
1096
  <h3>1) "How to get support?"</h3>
1097
  You can inform any problem related to the Premium version in the email above. It will be solved as soon as possible and without any cost.<br><br>
1098
  <h3>2) "Which plugins are compatible with Premium version?"</h3>
1099
+ WooCommerce, WP All Import, Monarch, Frontend Publishing and others. If you intend to use the Premium version with a specific plugin, you can ask me if they are compatible.<br><br>
1100
  <h3>3) "Can I get my money back later?"</h3>
1101
  With the exception of rare situations, no. But don't worry about that. You will still have the best support and if, after your complete cooperation, I'm not able to solve your issue, I may refund you.<br><br>
1102
  <h3>4) "How to get the Premium version?"</h3>
1109
  </form>
1110
  </div>
1111
  <div style="display:inline-block;top:-20px;position:relative">
1112
+ (US$ 50 or more, please) and receive the Premium version by email within 12 hours.
1113
  </div>
1114
  </div>
1115
  </div>
1120
  Hi! I'm Marcel Jacques Machado. Graduated in Computer Science, I work as a Software Engineer for 10 years. I already worked with C, Python, Shell Script and other programming languages and technologies. Nowadays, I develop web applications in Brazil using Java. About PHP, this plugin, Featured Image From URL, has been a great pratical experience.
1121
  </div>
1122
  </div>
1123
+ </div>
admin/html/meta-box.html CHANGED
@@ -49,12 +49,10 @@
49
  <div style="<?php echo $show_news?>">
50
  <br>
51
  <hr>
52
- <p style="font-size: 12px; padding: 5px; border-left: 6px solid orange; color: black;
53
- background-color: #eee; border-radius: 15px 50px;">new support email: support@featuredimagefromurl.com</p>
54
- <p style="font-size: 12px; padding: 5px; border-left: 6px solid #fe0072; color: black;
55
- background-color: #eee; border-radius: 15px 50px;">new size for external thumbnail feature: 1600px on longest one</p>
56
- <p style="font-size: 12px; padding: 5px; border-left: 6px solid #0073aa; color: black;
57
- background-color: #eee; border-radius: 15px 50px;">premium version supports videos from Vimeo now</p>
58
  <center>
59
  <table>
60
  <tbody>
@@ -68,4 +66,4 @@
68
  </tbody>
69
  </table>
70
  </center>
71
- </div>
49
  <div style="<?php echo $show_news?>">
50
  <br>
51
  <hr>
52
+ <p style="font-size: 12px; padding: 5px; border-left: 6px solid #ff5400; color: black;
53
+ background-color: #eee; border-radius: 15px 50px;">New premium feature: WP REST API integration</p>
54
+ <p style="font-size: 12px; padding: 5px; border-left: 6px solid #c60013; color: black;
55
+ background-color: #eee; border-radius: 15px 50px;">Allows to set player parameters for YouTube videos now</p>
 
 
56
  <center>
57
  <table>
58
  <tbody>
66
  </tbody>
67
  </table>
68
  </center>
69
+ </div>
admin/html/txt/post.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "publish",
3
+ "content": "I'm using WP REST API!",
4
+ "title": "Featured Image from URL",
5
+ "excerpt": "My first post...",
6
+ "fifu_image_url": "http://ps.w.org/featured-image-from-url/assets/icon-256x256.png",
7
+ "fifu_image_alt": "Logo"
8
+ }
admin/html/txt/product.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Featured Image from URL",
3
+ "meta_data": [
4
+ {
5
+ "key": "fifu_image_url",
6
+ "value": "http://ps.w.org/featured-image-from-url/assets/icon-256x256.png"
7
+ },
8
+ {
9
+ "key": "fifu_image_alt",
10
+ "value": "Logo"
11
+ }
12
+ ]
13
+ }
admin/meta-box.php CHANGED
@@ -3,24 +3,24 @@
3
  add_action('add_meta_boxes', 'fifu_insert_meta_box');
4
 
5
  function fifu_insert_meta_box() {
6
- $post_types = array('post', 'page', 'product', get_option('fifu_cpt0'), get_option('fifu_cpt1'), get_option('fifu_cpt2'), get_option('fifu_cpt3'), get_option('fifu_cpt4'));
 
 
 
 
 
 
 
 
 
7
 
8
  foreach ($post_types as $post_type) {
9
  if ($post_type == 'product') {
10
- add_meta_box(
11
- 'urlMetaBox', 'Product Image from URL', 'fifu_show_elements', $post_type, 'side', 'low'
12
- );
13
- if (get_option('fifu_woocommerce') == 'toggleon') {
14
- add_meta_box(
15
- 'wooCommerceGalleryMetaBox', 'Product Gallery from URL', 'fifu_wc_show_elements', $post_type, 'side', 'low'
16
- );
17
- }
18
- } else {
19
- if ($post_type)
20
- add_meta_box(
21
- 'imageUrlMetaBox', 'Featured Image from URL', 'fifu_show_elements', $post_type, 'side', 'low'
22
- );
23
- }
24
  }
25
  }
26
 
@@ -70,9 +70,9 @@ function fifu_wc_show_elements($post) {
70
  }
71
  }
72
 
73
- add_filter('wp_insert_post_data', 'fifu_remove_fist_image', 10, 2);
74
 
75
- function fifu_remove_fist_image($data, $postarr) {
76
  $content = $postarr['post_content'];
77
  if (!$content)
78
  return $data;
@@ -93,44 +93,37 @@ function fifu_remove_fist_image($data, $postarr) {
93
  add_action('save_post', 'fifu_save_properties');
94
 
95
  function fifu_save_properties($post_id) {
 
96
  if (isset($_POST['fifu_input_url'])) {
97
- $first = fifu_first_url_in_content($post_id);
98
  $url = esc_url($_POST['fifu_input_url']);
99
-
100
  if ($first && get_option('fifu_get_first') == 'toggleon' && (!$url || get_option('fifu_ovw_first') == 'toggleon'))
101
  $url = $first;
102
-
103
- update_post_meta($post_id, 'fifu_image_url', $url);
104
-
105
- if (get_option('fifu_attachment_id') && !get_post_thumbnail_id($post_id) && $url)
106
- set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
107
  }
108
 
109
- if (isset($_POST['fifu_input_alt']))
110
- update_post_meta($post_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
 
 
 
111
 
 
112
  if (get_post_type(get_the_ID()) == 'product') {
113
- $count = 10;
114
  for ($i = 0; $i < 10; $i++) {
115
  if (isset($_POST['fifu_input_url_' . $i]) && isset($_POST['fifu_input_alt_' . $i])) {
116
- if ($_POST['fifu_input_url_' . $i] != '' && $_POST['fifu_input_alt_' . $i] != '') {
117
- update_post_meta($post_id, 'fifu_image_url_' . $i, esc_url($_POST['fifu_input_url_' . $i]));
118
- update_post_meta($post_id, 'fifu_image_alt_' . $i, wp_strip_all_tags($_POST['fifu_input_alt_' . $i]));
119
- if (get_option('fifu_attachment_id') && !get_post_thumbnail_id($post_id) && esc_url($_POST['fifu_input_url_' . $i]))
120
- set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
121
- } else {
122
- delete_post_meta($post_id, 'fifu_image_url_' . $i);
123
- delete_post_meta($post_id, 'fifu_image_alt_' . $i);
124
- $count--;
125
- }
126
- } else
127
- $count--;
128
  }
129
- if ($count == 0 && (isset($_POST['fifu_input_url']) && !esc_url($_POST['fifu_input_url'])) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
130
- delete_post_thumbnail($post_id);
131
- }
132
- else {
133
- if ((isset($_POST['fifu_input_url']) && !esc_url($_POST['fifu_input_url'])) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id') && get_option('fifu_attachment_id') != null)
134
- delete_post_thumbnail($post_id);
135
  }
136
  }
 
 
 
 
 
 
 
3
  add_action('add_meta_boxes', 'fifu_insert_meta_box');
4
 
5
  function fifu_insert_meta_box() {
6
+ $post_types = array(
7
+ 'post',
8
+ 'page',
9
+ 'product',
10
+ get_option('fifu_cpt0'),
11
+ get_option('fifu_cpt1'),
12
+ get_option('fifu_cpt2'),
13
+ get_option('fifu_cpt3'),
14
+ get_option('fifu_cpt4')
15
+ );
16
 
17
  foreach ($post_types as $post_type) {
18
  if ($post_type == 'product') {
19
+ add_meta_box('urlMetaBox', 'Product Image from URL', 'fifu_show_elements', $post_type, 'side', 'low');
20
+ if (get_option('fifu_woocommerce') == 'toggleon')
21
+ add_meta_box('wooCommerceGalleryMetaBox', 'Product Gallery from URL', 'fifu_wc_show_elements', $post_type, 'side', 'low');
22
+ } else if ($post_type)
23
+ add_meta_box('imageUrlMetaBox', 'Featured Image from URL', 'fifu_show_elements', $post_type, 'side', 'low');
 
 
 
 
 
 
 
 
 
24
  }
25
  }
26
 
70
  }
71
  }
72
 
73
+ add_filter('wp_insert_post_data', 'fifu_remove_first_image', 10, 2);
74
 
75
+ function fifu_remove_first_image($data, $postarr) {
76
  $content = $postarr['post_content'];
77
  if (!$content)
78
  return $data;
93
  add_action('save_post', 'fifu_save_properties');
94
 
95
  function fifu_save_properties($post_id) {
96
+ /* image url */
97
  if (isset($_POST['fifu_input_url'])) {
 
98
  $url = esc_url($_POST['fifu_input_url']);
99
+ $first = fifu_first_url_in_content($post_id);
100
  if ($first && get_option('fifu_get_first') == 'toggleon' && (!$url || get_option('fifu_ovw_first') == 'toggleon'))
101
  $url = $first;
102
+ fifu_update_or_delete($post_id, 'fifu_image_url', $url);
 
 
 
 
103
  }
104
 
105
+ /* alt */
106
+ if (isset($_POST['fifu_input_alt'])) {
107
+ $alt = wp_strip_all_tags($_POST['fifu_input_alt']);
108
+ fifu_update_or_delete($post_id, 'fifu_image_alt', $alt);
109
+ }
110
 
111
+ /* gallery */
112
  if (get_post_type(get_the_ID()) == 'product') {
 
113
  for ($i = 0; $i < 10; $i++) {
114
  if (isset($_POST['fifu_input_url_' . $i]) && isset($_POST['fifu_input_alt_' . $i])) {
115
+ $url = esc_url($_POST['fifu_input_url_' . $i]);
116
+ $alt = wp_strip_all_tags($_POST['fifu_input_alt_' . $i]);
117
+ fifu_update_or_delete($post_id, 'fifu_image_url_' . $i, $url);
118
+ fifu_update_or_delete($post_id, 'fifu_image_alt_' . $i, $alt);
119
+ }
 
 
 
 
 
 
 
120
  }
 
 
 
 
 
 
121
  }
122
  }
123
+
124
+ function fifu_update_or_delete($post_id, $field, $url) {
125
+ if ($url)
126
+ update_post_meta($post_id, $field, $url);
127
+ else
128
+ delete_post_meta($post_id, $field, $url);
129
+ }
featured-image-from-url.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * 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.
6
- * Version: 1.5.9
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://featuredimagefromurl.com/
9
  */
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * 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.
6
+ * Version: 1.6.0
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://featuredimagefromurl.com/
9
  */
includes/external-post.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
- add_filter('wp_insert_post_data', 'fifu_remove_fist_image_ext', 10, 2);
4
 
5
- function fifu_remove_fist_image_ext($data, $postarr) {
6
  if (isset($_POST['fifu_input_url']))
7
  return $data;
8
 
@@ -33,9 +33,6 @@ function fifu_save_properties_ext($post_id) {
33
 
34
  if ($url && get_option('fifu_get_first') == 'toggleon')
35
  update_post_meta($post_id, 'fifu_image_url', $url);
36
-
37
- if (get_option('fifu_attachment_id') && !get_post_thumbnail_id($post_id) && $url)
38
- set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
39
  }
40
 
41
  function fifu_first_img_in_content($content) {
@@ -69,6 +66,8 @@ function fifu_first_url_in_content($post_id) {
69
  return;
70
  $matches = array();
71
  preg_match_all('/<img[^>]*>/', $content, $matches);
 
 
72
  $aux1 = explode('src="', $matches[0][0]);
73
  $aux2 = explode('"', $aux1[1]);
74
  return $matches && $matches[0] ? $aux2[0] : null;
1
  <?php
2
 
3
+ add_filter('wp_insert_post_data', 'fifu_remove_first_image_ext', 10, 2);
4
 
5
+ function fifu_remove_first_image_ext($data, $postarr) {
6
  if (isset($_POST['fifu_input_url']))
7
  return $data;
8
 
33
 
34
  if ($url && get_option('fifu_get_first') == 'toggleon')
35
  update_post_meta($post_id, 'fifu_image_url', $url);
 
 
 
36
  }
37
 
38
  function fifu_first_img_in_content($content) {
66
  return;
67
  $matches = array();
68
  preg_match_all('/<img[^>]*>/', $content, $matches);
69
+ if (!$matches[0])
70
+ return;
71
  $aux1 = explode('src="', $matches[0][0]);
72
  $aux2 = explode('"', $aux1[1]);
73
  return $matches && $matches[0] ? $aux2[0] : null;
includes/thumbnail.php CHANGED
@@ -71,29 +71,23 @@ function fifu_add_to_content($content) {
71
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
72
 
73
  function fifu_replace_attachment_url($att_url, $att_id) {
74
- if (get_option('fifu_attachment_id') == $att_id) {
75
- if (!is_admin()) {
76
- $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
77
- if ($url)
78
- $att_url = $url;
79
- }
80
- }
81
  return $att_url;
82
  }
83
 
84
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 2);
85
 
86
  function fifu_replace_attachment_image_src($image, $attachment_id) {
87
- if ($attachment_id == get_post_thumbnail_id(get_the_ID())) {
88
- $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
89
- if ($url) {
90
- return array(
91
- $url,
92
- 0,
93
- 0,
94
- false
95
- );
96
- }
97
  }
98
  return $image;
99
  }
71
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
72
 
73
  function fifu_replace_attachment_url($att_url, $att_id) {
74
+ $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
75
+ if ($url)
76
+ return $url;
 
 
 
 
77
  return $att_url;
78
  }
79
 
80
  add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 2);
81
 
82
  function fifu_replace_attachment_image_src($image, $attachment_id) {
83
+ $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
84
+ if ($url) {
85
+ return array(
86
+ $url,
87
+ 0,
88
+ 0,
89
+ false
90
+ );
 
 
91
  }
92
  return $image;
93
  }
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
4
- Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
  Stable tag: 4.8
@@ -28,6 +28,8 @@ Features:
28
 
29
  * compatible with WP All Import plugin;
30
 
 
 
31
  * all features created for external images are available for external videos from YouTube and Vimeo. And you can define the video size for each screen type (**premium feature**);
32
 
33
  * you can use a slider of images as featured image (**premium feature**);
@@ -274,6 +276,9 @@ was removed. To finish, a Premium version is now been presented.
274
  = 1.5.9 =
275
  * New support email.
276
 
 
 
 
277
  == Upgrade Notice ==
278
 
279
  = 1.0 =
@@ -408,3 +413,6 @@ was removed. To finish, a Premium version is now been presented.
408
 
409
  = 1.5.9 =
410
  * New support email.
 
 
 
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
4
+ Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate, wp, rest, api, wp rest api
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
  Stable tag: 4.8
28
 
29
  * compatible with WP All Import plugin;
30
 
31
+ * supports WP REST API (**premium feature**);
32
+
33
  * all features created for external images are available for external videos from YouTube and Vimeo. And you can define the video size for each screen type (**premium feature**);
34
 
35
  * you can use a slider of images as featured image (**premium feature**);
276
  = 1.5.9 =
277
  * New support email.
278
 
279
+ = 1.6.0 =
280
+ * WP REST API.
281
+
282
  == Upgrade Notice ==
283
 
284
  = 1.0 =
413
 
414
  = 1.5.9 =
415
  * New support email.
416
+
417
+ = 1.6.0 =
418
+ * WP REST API.