Featured Image From URL - Version 1.9.7

Version Description

  • If jQuery is not found, get that from a CDN.
Download this release

Release Info

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

Code changes from version 1.9.6 to 1.9.7

admin/html/css/category.css CHANGED
@@ -17,4 +17,3 @@
17
  font-style: italic;
18
  color: #999;
19
  }
20
-
17
  font-style: italic;
18
  color: #999;
19
  }
 
admin/html/css/menu.css CHANGED
@@ -18,8 +18,6 @@
18
  }
19
 
20
  .greybox p {
21
- font-style: italic;
22
- color: #000000;
23
  }
24
 
25
  .toggleon, .toggleoff {
@@ -35,18 +33,6 @@
35
  background: url("<?php echo $image_button ?>") -72px 0 no-repeat;
36
  }
37
 
38
- .fifubox {
39
- border: 1px;
40
- color: black;
41
- padding: 15px 32px;
42
- text-align: center;
43
- text-decoration: none;
44
- display: inline-block;
45
- font-size: 16px;
46
- margin: 4px 2px;
47
- border-style: solid;
48
- }
49
-
50
  th, td {
51
  border-bottom: 1px solid #ddd;
52
  padding-right: 32px;
@@ -57,9 +43,6 @@ th {
57
  height: 25px;
58
  }
59
 
60
- #grad1 {
61
- }
62
-
63
  #grad2 {
64
  border: 1px solid red;
65
  border-radius: 15px;
18
  }
19
 
20
  .greybox p {
 
 
21
  }
22
 
23
  .toggleon, .toggleoff {
33
  background: url("<?php echo $image_button ?>") -72px 0 no-repeat;
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  th, td {
37
  border-bottom: 1px solid #ddd;
38
  padding-right: 32px;
43
  height: 25px;
44
  }
45
 
 
 
 
46
  #grad2 {
47
  border: 1px solid red;
48
  border-radius: 15px;
admin/html/menu.html CHANGED
@@ -37,7 +37,7 @@
37
  <div class="box">
38
 
39
  <h2>Auto Set Featured Image: configuration</h2>
40
- <div class="greybox" id="grad1">
41
  Perfect for external posts, this option allows to use the first image from a post/page/product content as featured image. It will happen when you click on Publish/Update button.
42
  </div>
43
 
@@ -128,7 +128,7 @@
128
 
129
  <div class="box">
130
  <h2>Custom Post Types</h2>
131
- <div class="greybox" id="grad1">
132
  Featured Image from URL is preconfigured to work with only one Custom Post Type (WooCommerce Product). But you also can use this plugin with other ones. For that, you just need to know the correct Custom Post Type names and fill the fields below. Please, let me know if you need more than 5 inputs here.
133
  </div>
134
  <br>
@@ -150,7 +150,7 @@
150
 
151
  <div class="box">
152
  <h2>CSS Style</h2>
153
- <div class="greybox" id="grad1">
154
  Here you can define a CSS style to be applied to all external featured images. Usage example:<br><br>
155
  width: 100%; border-radius: 8px; border: 1px solid #ddd; padding: 5px;
156
  <br><br>
@@ -197,7 +197,7 @@
197
 
198
  <div class="box">
199
  <h2>Fake Internal Featured Image</h2>
200
- <div class="greybox" id="grad1">
201
  Even though FIFU works fine with the most of themes/plugins, some of them are not able to show the external featured image if there is no internal featured image associated to your post/page/product. Enabling the toggle below, a symbolic empty file will be added to your Media Library as an attempt to overcome that limitation.
202
  </div>
203
  <p/>
@@ -224,7 +224,7 @@
224
 
225
  <div class="box">
226
  <h2>Featured Image Column</h2>
227
- <div class="greybox" id="grad1">
228
  The plugin adds a new column "FIFU" (Featured Image from URL) to your table of posts/pages/products in admin area. Below you can choose the height (px) of the image in the column. To disable that, just uncheck "FIFU" in the Screen Options.
229
  </div>
230
  <br>
@@ -239,7 +239,7 @@
239
 
240
  <div class="box">
241
  <h2>Featured Image in Content</h2>
242
- <div class="greybox" id="grad1">
243
  It will sound crazy, but some themes don't show the Featured Image on the posts or pages. If it is your case and you would like to show the Featured Image there, just enable the toggle. The Featured Image will appear at the beginning of the content, before the text.
244
  </div>
245
  <br>
@@ -266,7 +266,7 @@
266
 
267
  <div class="box">
268
  <h2>Hide Featured Media</h2>
269
- <div class="greybox" id="grad1">
270
  Enable the toggle if you want to hide the external featured image/video/slider on posts/pages but keeping its visibility on home.
271
  </div>
272
  <br>
@@ -328,7 +328,7 @@
328
 
329
  <div class="box">
330
  <h2>Lazy Load</h2>
331
- <div class="greybox" id="grad1">
332
  Enabling this feature the images/videos won't be loaded until user scrolls to them. So it will make your home/shop load faster.
333
  </div>
334
  <br>
@@ -357,7 +357,7 @@
357
 
358
  <div class="box">
359
  <h2>Priority</h2>
360
- <div class="greybox" id="grad1">
361
  Enable the toggle below to prioritize the internal image rather than the external one, if both exist.
362
  </div>
363
  <br>
@@ -394,7 +394,7 @@
394
 
395
  <div class="box">
396
  <h2>Social Tags</h2>
397
- <div class="greybox" id="grad1">
398
  Featured Image from URL provides social tags to share the external images on the social networks. Here you can enable/disable this feature.
399
  </div>
400
  <br>
@@ -421,7 +421,7 @@
421
 
422
  <div class="box">
423
  <h2>WooCommerce</h2>
424
- <div class="greybox" id="grad1">
425
  You can disable the product lightbox and zoom here once these features are only compatible with the premium version.
426
  </div>
427
  <br>
@@ -485,7 +485,7 @@
485
 
486
  <div class="box">
487
  <h2>WP All Import</h2>
488
- <div class="greybox" id="grad1">
489
  You can use Featured Image from URL with WP All Import plugin. For that, use the custom field <b>fifu_image_url</b>.<br/><br/> The other custom fields supported by FIFU are listed below, in the section WP REST API > Plugin Fields.
490
  <br/><br/>
491
  <div class="greybox" id="grad2">
37
  <div class="box">
38
 
39
  <h2>Auto Set Featured Image: configuration</h2>
40
+ <div class="greybox">
41
  Perfect for external posts, this option allows to use the first image from a post/page/product content as featured image. It will happen when you click on Publish/Update button.
42
  </div>
43
 
128
 
129
  <div class="box">
130
  <h2>Custom Post Types</h2>
131
+ <div class="greybox">
132
  Featured Image from URL is preconfigured to work with only one Custom Post Type (WooCommerce Product). But you also can use this plugin with other ones. For that, you just need to know the correct Custom Post Type names and fill the fields below. Please, let me know if you need more than 5 inputs here.
133
  </div>
134
  <br>
150
 
151
  <div class="box">
152
  <h2>CSS Style</h2>
153
+ <div class="greybox">
154
  Here you can define a CSS style to be applied to all external featured images. Usage example:<br><br>
155
  width: 100%; border-radius: 8px; border: 1px solid #ddd; padding: 5px;
156
  <br><br>
197
 
198
  <div class="box">
199
  <h2>Fake Internal Featured Image</h2>
200
+ <div class="greybox">
201
  Even though FIFU works fine with the most of themes/plugins, some of them are not able to show the external featured image if there is no internal featured image associated to your post/page/product. Enabling the toggle below, a symbolic empty file will be added to your Media Library as an attempt to overcome that limitation.
202
  </div>
203
  <p/>
224
 
225
  <div class="box">
226
  <h2>Featured Image Column</h2>
227
+ <div class="greybox">
228
  The plugin adds a new column "FIFU" (Featured Image from URL) to your table of posts/pages/products in admin area. Below you can choose the height (px) of the image in the column. To disable that, just uncheck "FIFU" in the Screen Options.
229
  </div>
230
  <br>
239
 
240
  <div class="box">
241
  <h2>Featured Image in Content</h2>
242
+ <div class="greybox">
243
  It will sound crazy, but some themes don't show the Featured Image on the posts or pages. If it is your case and you would like to show the Featured Image there, just enable the toggle. The Featured Image will appear at the beginning of the content, before the text.
244
  </div>
245
  <br>
266
 
267
  <div class="box">
268
  <h2>Hide Featured Media</h2>
269
+ <div class="greybox">
270
  Enable the toggle if you want to hide the external featured image/video/slider on posts/pages but keeping its visibility on home.
271
  </div>
272
  <br>
328
 
329
  <div class="box">
330
  <h2>Lazy Load</h2>
331
+ <div class="greybox">
332
  Enabling this feature the images/videos won't be loaded until user scrolls to them. So it will make your home/shop load faster.
333
  </div>
334
  <br>
357
 
358
  <div class="box">
359
  <h2>Priority</h2>
360
+ <div class="greybox">
361
  Enable the toggle below to prioritize the internal image rather than the external one, if both exist.
362
  </div>
363
  <br>
394
 
395
  <div class="box">
396
  <h2>Social Tags</h2>
397
+ <div class="greybox">
398
  Featured Image from URL provides social tags to share the external images on the social networks. Here you can enable/disable this feature.
399
  </div>
400
  <br>
421
 
422
  <div class="box">
423
  <h2>WooCommerce</h2>
424
+ <div class="greybox">
425
  You can disable the product lightbox and zoom here once these features are only compatible with the premium version.
426
  </div>
427
  <br>
485
 
486
  <div class="box">
487
  <h2>WP All Import</h2>
488
+ <div class="greybox">
489
  You can use Featured Image from URL with WP All Import plugin. For that, use the custom field <b>fifu_image_url</b>.<br/><br/> The other custom fields supported by FIFU are listed below, in the section WP REST API > Plugin Fields.
490
  <br/><br/>
491
  <div class="greybox" id="grad2">
admin/menu.php CHANGED
@@ -37,7 +37,7 @@ function fifu_get_menu_html() {
37
 
38
  fifu_update_menu_options();
39
 
40
- if (get_option('fifu_fake') == 'toggleon')
41
  fifu_enable_fake();
42
  else
43
  fifu_disable_fake();
37
 
38
  fifu_update_menu_options();
39
 
40
+ if (fifu_is_on('fifu_fake'))
41
  fifu_enable_fake();
42
  else
43
  fifu_disable_fake();
admin/meta-box.php CHANGED
@@ -59,7 +59,7 @@ function fifu_remove_first_image($data, $postarr) {
59
  if (!$img)
60
  return $data;
61
 
62
- if (get_option('fifu_pop_first') == 'toggleoff')
63
  return str_replace($img, fifu_show_image($img), $data);
64
 
65
  return str_replace($img, fifu_hide_image($img), $data);
@@ -72,7 +72,7 @@ function fifu_save_properties($post_id) {
72
  if (isset($_POST['fifu_input_url'])) {
73
  $url = esc_url($_POST['fifu_input_url']);
74
  $first = fifu_first_url_in_content($post_id);
75
- if ($first && get_option('fifu_get_first') == 'toggleon' && (!$url || get_option('fifu_ovw_first') == 'toggleon'))
76
  $url = $first;
77
  fifu_update_or_delete($post_id, 'fifu_image_url', $url);
78
  }
59
  if (!$img)
60
  return $data;
61
 
62
+ if (fifu_is_off('fifu_pop_first'))
63
  return str_replace($img, fifu_show_image($img), $data);
64
 
65
  return str_replace($img, fifu_hide_image($img), $data);
72
  if (isset($_POST['fifu_input_url'])) {
73
  $url = esc_url($_POST['fifu_input_url']);
74
  $first = fifu_first_url_in_content($post_id);
75
+ if ($first && fifu_is_on('fifu_get_first') && (!$url || fifu_is_on('fifu_ovw_first')))
76
  $url = $first;
77
  fifu_update_or_delete($post_id, 'fifu_image_url', $url);
78
  }
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image From URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * 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.
7
- * Version: 1.9.6
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
@@ -17,6 +17,7 @@ require_once( FIFU_INCLUDES_DIR . '/thumbnail.php' );
17
  require_once( FIFU_INCLUDES_DIR . '/thumbnail-category.php' );
18
  require_once( FIFU_INCLUDES_DIR . '/external-post.php' );
19
  require_once( FIFU_INCLUDES_DIR . '/convert-url.php' );
 
20
  require_once (FIFU_INCLUDES_DIR . '/woo.php');
21
 
22
  if (is_admin()) {
4
  * Plugin Name: Featured Image From URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * 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.
7
+ * Version: 1.9.7
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
17
  require_once( FIFU_INCLUDES_DIR . '/thumbnail-category.php' );
18
  require_once( FIFU_INCLUDES_DIR . '/external-post.php' );
19
  require_once( FIFU_INCLUDES_DIR . '/convert-url.php' );
20
+ require_once (FIFU_INCLUDES_DIR . '/util.php');
21
  require_once (FIFU_INCLUDES_DIR . '/woo.php');
22
 
23
  if (is_admin()) {
includes/external-post.php CHANGED
@@ -17,7 +17,7 @@ function fifu_remove_first_image_ext($data, $postarr) {
17
  if (!$img)
18
  return $data;
19
 
20
- if (get_option('fifu_pop_first') == 'toggleoff')
21
  return str_replace($img, fifu_show_image($img), $data);
22
 
23
  return str_replace($img, fifu_hide_image($img), $data);
@@ -31,7 +31,7 @@ function fifu_save_properties_ext($post_id) {
31
 
32
  $url = fifu_first_url_in_content($post_id);
33
 
34
- if ($url && get_option('fifu_get_first') == 'toggleon') {
35
  update_post_meta($post_id, 'fifu_image_url', fifu_convert($url));
36
  fifu_update_fake_attach_id($post_id);
37
  }
17
  if (!$img)
18
  return $data;
19
 
20
+ if (fifu_is_off('fifu_pop_first'))
21
  return str_replace($img, fifu_show_image($img), $data);
22
 
23
  return str_replace($img, fifu_hide_image($img), $data);
31
 
32
  $url = fifu_first_url_in_content($post_id);
33
 
34
+ if ($url && fifu_is_on('fifu_get_first')) {
35
  update_post_meta($post_id, 'fifu_image_url', fifu_convert($url));
36
  fifu_update_fake_attach_id($post_id);
37
  }
includes/html/css/woo.css CHANGED
@@ -1,3 +1,3 @@
1
  img.zoomImg {
2
- display:<?php echo fifu_woo_zoom(); ?> !important;
3
  }
1
  img.zoomImg {
2
+ display:<?php echo fifu_woo_zoom(); ?> !important;
3
  }
includes/html/script.html CHANGED
@@ -1,3 +1,4 @@
 
1
  <style><?php include 'css/woo.css' ?></style>
2
 
3
  <script><?php include 'js/image.js' ?></script>
1
+ <script>window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"><\/script>')</script>
2
  <style><?php include 'css/woo.css' ?></style>
3
 
4
  <script><?php include 'js/image.js' ?></script>
includes/thumbnail-category.php CHANGED
@@ -20,7 +20,7 @@ function fifu_cat_add_social_tags() {
20
  if ($term_id)
21
  $description = wp_strip_all_tags(category_description($term_id));
22
 
23
- if ($url && get_option('fifu_social') == 'toggleon')
24
  include 'html/social.html';
25
  }
26
 
20
  if ($term_id)
21
  $description = wp_strip_all_tags(category_description($term_id));
22
 
23
+ if ($url && fifu_is_on('fifu_social'))
24
  include 'html/social.html';
25
  }
26
 
includes/thumbnail.php CHANGED
@@ -17,7 +17,7 @@ function fifu_add_social_tags() {
17
  $title = get_the_title($post_id);
18
  $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
19
 
20
- if ($url && get_option('fifu_social') == 'toggleon')
21
  include 'html/social.html';
22
  }
23
 
@@ -29,7 +29,7 @@ function fifu_add_sirv_js() {
29
  }
30
 
31
  function fifu_apply_css() {
32
- if (get_option('fifu_wc_lbox') == 'toggleoff')
33
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {display:none !important;}</style>';
34
  }
35
 
@@ -82,7 +82,7 @@ function fifu_get_html($url, $alt) {
82
  add_filter('the_content', 'fifu_add_to_content');
83
 
84
  function fifu_add_to_content($content) {
85
- if (is_singular() && has_post_thumbnail() && get_option('fifu_content') == 'toggleon')
86
  return get_the_post_thumbnail() . $content;
87
  else
88
  return $content;
@@ -123,7 +123,7 @@ function fifu_replace_attachment_image_src($image, $att_id) {
123
  }
124
 
125
  function fifu_should_hide() {
126
- return ((is_singular('post') && get_option('fifu_hide_post') == 'toggleon') || (is_singular('page') && get_option('fifu_hide_page') == 'toggleon'));
127
  }
128
 
129
  add_filter('genesis_get_image', 'fifu_genesis_image', 10, 4);
@@ -146,13 +146,13 @@ function fifu_no_internal_image($post_id) {
146
  }
147
 
148
  function fifu_lazy_url($url) {
149
- if (get_option('fifu_lazy') != 'toggleon' || is_ajax_call())
150
  return 'src="' . $url . '"';
151
  return (is_home() || (class_exists('WooCommerce') && is_shop()) ? 'data-src="' : 'src="') . $url . '"';
152
  }
153
 
154
  function fifu_is_fake_disabled() {
155
- return get_option('fifu_fake') == 'toggleoff';
156
  }
157
 
158
  function fifu_has_internal_image($post_id) {
@@ -171,5 +171,5 @@ function fifu_is_in_editor() {
171
  }
172
 
173
  function fifu_internal_priority() {
174
- return get_option('fifu_priority') == 'toggleon';
175
  }
17
  $title = get_the_title($post_id);
18
  $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
19
 
20
+ if ($url && fifu_is_on('fifu_social'))
21
  include 'html/social.html';
22
  }
23
 
29
  }
30
 
31
  function fifu_apply_css() {
32
+ if (fifu_is_off('fifu_wc_lbox'))
33
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {display:none !important;}</style>';
34
  }
35
 
82
  add_filter('the_content', 'fifu_add_to_content');
83
 
84
  function fifu_add_to_content($content) {
85
+ if (is_singular() && has_post_thumbnail() && fifu_is_on('fifu_content'))
86
  return get_the_post_thumbnail() . $content;
87
  else
88
  return $content;
123
  }
124
 
125
  function fifu_should_hide() {
126
+ return ((is_singular('post') && fifu_is_on('fifu_hide_post')) || (is_singular('page') && fifu_is_on('fifu_hide_page')));
127
  }
128
 
129
  add_filter('genesis_get_image', 'fifu_genesis_image', 10, 4);
146
  }
147
 
148
  function fifu_lazy_url($url) {
149
+ if (!fifu_is_on('fifu_lazy') || is_ajax_call())
150
  return 'src="' . $url . '"';
151
  return (is_home() || (class_exists('WooCommerce') && is_shop()) ? 'data-src="' : 'src="') . $url . '"';
152
  }
153
 
154
  function fifu_is_fake_disabled() {
155
+ return fifu_is_off('fifu_fake');
156
  }
157
 
158
  function fifu_has_internal_image($post_id) {
171
  }
172
 
173
  function fifu_internal_priority() {
174
+ return fifu_is_on('fifu_priority');
175
  }
includes/util.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function fifu_get_img_width_from_html($html) {
4
+ $aux = explode('img width=', $html)[1];
5
+ return explode('"', $aux)[1];
6
+ }
7
+
8
+ function fifu_get_src_from_html($html) {
9
+ $aux = explode('src=', $html)[1];
10
+ return explode('"', $aux)[1];
11
+ }
12
+
13
+ function fifu_get_data_large_from_html($html) {
14
+ $aux = explode('data-large_image=', $html);
15
+ $aux = $aux && count($aux) > 1 ? $aux[1] : null;
16
+ $url = $aux ? explode('"', $aux)[1] : null;
17
+ return $url;
18
+ }
19
+
20
+ function fifu_is_on($option) {
21
+ return get_option($option) == 'toggleon';
22
+ }
23
+
24
+ function fifu_is_off($option) {
25
+ return get_option($option) == 'toggleoff';
26
+ }
27
+
includes/woo.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
 
3
  function fifu_woo_zoom() {
4
- return get_option('fifu_wc_zoom') == 'toggleon' ? 'inline' : 'none';
5
  }
6
 
7
  function fifu_woo_lbox() {
8
- return get_option('fifu_wc_lbox') == 'toggleon';
9
  }
10
 
11
  function fifu_woo_theme() {
1
  <?php
2
 
3
  function fifu_woo_zoom() {
4
+ return fifu_is_on('fifu_wc_zoom') ? 'inline' : 'none';
5
  }
6
 
7
  function fifu_woo_lbox() {
8
+ return fifu_is_on('fifu_wc_lbox');
9
  }
10
 
11
  function fifu_woo_theme() {
readme.txt CHANGED
@@ -159,6 +159,12 @@ Features:
159
 
160
  == Changelog ==
161
 
 
 
 
 
 
 
162
  = 1.9.5 =
163
  * Back to the version 1.9.1.
164
 
@@ -402,6 +408,12 @@ was removed. To finish, a Premium version is now been presented.
402
 
403
  == Upgrade Notice ==
404
 
 
 
 
 
 
 
405
  = 1.9.5 =
406
  * Back to the version 1.9.1.
407
 
159
 
160
  == Changelog ==
161
 
162
+ = 1.9.7 =
163
+ * If jQuery is not found, get that from a CDN.
164
+
165
+ = 1.9.6 =
166
+ * Update warning.
167
+
168
  = 1.9.5 =
169
  * Back to the version 1.9.1.
170
 
408
 
409
  == Upgrade Notice ==
410
 
411
+ = 1.9.7 =
412
+ * If jQuery is not found, get that from a CDN.
413
+
414
+ = 1.9.6 =
415
+ * Update warning.
416
+
417
  = 1.9.5 =
418
  * Back to the version 1.9.1.
419