Featured Image From URL - Version 1.6.6

Version Description

  • Support to Google Drive images.

=

Download this release

Release Info

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

Code changes from version 1.6.5 to 1.6.6

admin/category.php CHANGED
@@ -10,9 +10,12 @@ function fifu_cat_show_box($term) {
10
  $align = 'text-align:left;';
11
  $show_news = 'display:none';
12
  $is_sirv_active = is_plugin_active('sirv/sirv.php');
 
13
 
14
- $url = get_term_meta($term->term_id, 'fifu_image_url', true);
15
- $alt = get_term_meta($term->term_id, 'fifu_image_alt', true);
 
 
16
 
17
  if ($url)
18
  $show_button = $show_sirv = 'display:none;';
@@ -29,7 +32,7 @@ add_action('create_product_cat', 'fifu_cat_save_properties', 10, 2);
29
 
30
  function fifu_cat_save_properties($term_id) {
31
  if (isset($_POST['fifu_input_url']))
32
- update_term_meta($term_id, 'fifu_image_url', esc_url($_POST['fifu_input_url']));
33
 
34
  if (isset($_POST['fifu_input_alt']))
35
  update_term_meta($term_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
10
  $align = 'text-align:left;';
11
  $show_news = 'display:none';
12
  $is_sirv_active = is_plugin_active('sirv/sirv.php');
13
+ $url = $alt = $show_button = $show_alt = $show_image = $show_link = null;
14
 
15
+ if (is_object($term)) {
16
+ $url = get_term_meta($term->term_id, 'fifu_image_url', true);
17
+ $alt = get_term_meta($term->term_id, 'fifu_image_alt', true);
18
+ }
19
 
20
  if ($url)
21
  $show_button = $show_sirv = 'display:none;';
32
 
33
  function fifu_cat_save_properties($term_id) {
34
  if (isset($_POST['fifu_input_url']))
35
+ update_term_meta($term_id, 'fifu_image_url', fifu_convert(esc_url($_POST['fifu_input_url'])));
36
 
37
  if (isset($_POST['fifu_input_alt']))
38
  update_term_meta($term_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
admin/html/js/convert-url.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function fifu_convert($url) {
2
+ if (fifu_from_google_drive($url))
3
+ return fifu_google_drive_url($url);
4
+
5
+ return $url;
6
+ }
7
+
8
+ function fifu_from_google_drive($url) {
9
+ return $url.includes('drive.google.com');
10
+ }
11
+
12
+ function fifu_google_drive_id($url) {
13
+ return $url.match(/[-\w]{25,}/);
14
+ }
15
+
16
+ function fifu_google_drive_url($url) {
17
+ return 'https://drive.google.com/uc?id=' + fifu_google_drive_id($url);
18
+ }
admin/html/js/meta-box.js CHANGED
@@ -14,6 +14,7 @@ function removeImage() {
14
 
15
  function previewImage() {
16
  var $url = jQuery("#fifu_input_url").val();
 
17
 
18
  if ($url) {
19
  jQuery("#fifu_button").hide();
14
 
15
  function previewImage() {
16
  var $url = jQuery("#fifu_input_url").val();
17
+ $url = fifu_convert($url);
18
 
19
  if ($url) {
20
  jQuery("#fifu_button").hide();
admin/html/js/wc-meta-box.js CHANGED
@@ -1,38 +1,39 @@
1
  function wcRemoveImage(i) {
2
- var inputUrl = "#fifu_input_url_" + i;
3
- var button = "#fifu_button_" + i;
4
- var image = "#fifu_image_" + i;
5
- var inputAlt = "#fifu_input_alt_" + i;
6
- var link = "#fifu_link_" + i;
7
 
8
- jQuery(inputAlt).hide();
9
- jQuery(image).hide();
10
- jQuery(link).hide();
11
 
12
- jQuery(inputAlt).val("");
13
- jQuery(inputUrl).val("");
14
 
15
- jQuery(inputUrl).show();
16
- jQuery(button).show();
17
  }
18
 
19
  function wcPreviewImage(i) {
20
- var inputUrl = "#fifu_input_url_" + i;
21
- var button = "#fifu_button_" + i;
22
- var image = "#fifu_image_" + i;
23
- var inputAlt = "#fifu_input_alt_" + i;
24
- var link = "#fifu_link_" + i;
25
 
26
- var $url = jQuery(inputUrl).val();
 
27
 
28
- if ($url) {
29
- jQuery(inputUrl).hide();
30
- jQuery(button).hide();
31
 
32
- jQuery(image).css('background-image', "url('" + $url + "')");
33
 
34
- jQuery(inputAlt).show();
35
- jQuery(image).show();
36
- jQuery(link).show();
37
- }
38
  }
1
  function wcRemoveImage(i) {
2
+ var inputUrl = "#fifu_input_url_" + i;
3
+ var button = "#fifu_button_" + i;
4
+ var image = "#fifu_image_" + i;
5
+ var inputAlt = "#fifu_input_alt_" + i;
6
+ var link = "#fifu_link_" + i;
7
 
8
+ jQuery(inputAlt).hide();
9
+ jQuery(image).hide();
10
+ jQuery(link).hide();
11
 
12
+ jQuery(inputAlt).val("");
13
+ jQuery(inputUrl).val("");
14
 
15
+ jQuery(inputUrl).show();
16
+ jQuery(button).show();
17
  }
18
 
19
  function wcPreviewImage(i) {
20
+ var inputUrl = "#fifu_input_url_" + i;
21
+ var button = "#fifu_button_" + i;
22
+ var image = "#fifu_image_" + i;
23
+ var inputAlt = "#fifu_input_alt_" + i;
24
+ var link = "#fifu_link_" + i;
25
 
26
+ var $url = jQuery(inputUrl).val();
27
+ $url = fifu_convert($url);
28
 
29
+ if ($url) {
30
+ jQuery(inputUrl).hide();
31
+ jQuery(button).hide();
32
 
33
+ jQuery(image).css('background-image', "url('" + $url + "')");
34
 
35
+ jQuery(inputAlt).show();
36
+ jQuery(image).show();
37
+ jQuery(link).show();
38
+ }
39
  }
admin/html/meta-box.html CHANGED
@@ -1,4 +1,5 @@
1
  <script><?php include 'js/meta-box.js' ?></script>
 
2
 
3
  <!-- show alt field, image and link if URL was already provided -->
4
 
@@ -49,14 +50,12 @@
49
  <div style="<?php echo $show_news?>">
50
  <br>
51
  <hr>
 
 
52
  <p style="font-size: 12px; padding: 5px; border-left: 6px solid green; color: black;
53
  background-color: #eee; border-radius: 15px 50px;">New free feature: Lazy Load</p>
54
  <p style="font-size: 12px; padding: 5px; border-left: 6px solid #ff5400; color: black;
55
  background-color: #eee; border-radius: 15px 50px;">New premium feature: WP REST API integration</p>
56
- <p style="font-size: 12px; padding: 5px; border-left: 6px solid #c60013; color: black;
57
- background-color: #eee; border-radius: 15px 50px;">Allows to set player parameters for YouTube videos now</p>
58
- <p style="font-size: 12px; padding: 5px; border-left: 6px solid black; color: black;
59
- background-color: #eee; border-radius: 15px 50px;"><a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">Vote</a> on the next free plugin feature</p>
60
  <center>
61
  <table>
62
  <tbody>
1
  <script><?php include 'js/meta-box.js' ?></script>
2
+ <script><?php include 'js/convert-url.js' ?></script>
3
 
4
  <!-- show alt field, image and link if URL was already provided -->
5
 
50
  <div style="<?php echo $show_news?>">
51
  <br>
52
  <hr>
53
+ <p style="font-size: 12px; padding: 5px; border-left: 6px solid blue; color: black;
54
+ background-color: #eee; border-radius: 15px 50px;">New free feature: support to Google Drive images (25% <a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">votes</a>)</p>
55
  <p style="font-size: 12px; padding: 5px; border-left: 6px solid green; color: black;
56
  background-color: #eee; border-radius: 15px 50px;">New free feature: Lazy Load</p>
57
  <p style="font-size: 12px; padding: 5px; border-left: 6px solid #ff5400; color: black;
58
  background-color: #eee; border-radius: 15px 50px;">New premium feature: WP REST API integration</p>
 
 
 
 
59
  <center>
60
  <table>
61
  <tbody>
admin/html/wc-meta-box.html CHANGED
@@ -1,13 +1,14 @@
1
  <script><?php include 'js/wc-meta-box.js' ?></script>
 
2
 
3
  <!-- show alt field, remove button and image if URL was already provided -->
4
 
5
  <input id="fifu_input_alt_<?php echo $i; ?>"
6
- type="text"
7
- name="fifu_input_alt_<?php echo $i; ?>"
8
- placeholder="alt attribute (required)"
9
- value="<?php echo $alt[$i]; ?>"
10
- style="<?php echo $altWidth, $show_alt[$i] ?>" />
11
 
12
  <a id="fifu_link_<?php echo $i; ?>"
13
  class="button"
@@ -16,19 +17,19 @@
16
  style="<?php echo $show_link[$i] ?>" >x</a>
17
 
18
  <div id="fifu_image_<?php echo $i; ?>"
19
- style="<?php echo $height, $margin, $show_image[$i] ?>
20
- background:url('<?php echo $url[$i]; ?>') no-repeat center center;
21
- background-size:cover;" >
22
  </div>
23
 
24
  <!-- show URL field and preview button if URL was not provided yet -->
25
 
26
  <input id="fifu_input_url_<?php echo $i; ?>"
27
- type="text"
28
- name="fifu_input_url_<?php echo $i; ?>"
29
- placeholder="URL"
30
- value="<?php echo $url[$i]; ?>"
31
- style="<?php echo $width, $margin, $show_url[$i] ?>" />
32
 
33
  <a id="fifu_button_<?php echo $i; ?>"
34
  class="button"
1
  <script><?php include 'js/wc-meta-box.js' ?></script>
2
+ <script><?php include 'js/convert-url.js' ?></script>
3
 
4
  <!-- show alt field, remove button and image if URL was already provided -->
5
 
6
  <input id="fifu_input_alt_<?php echo $i; ?>"
7
+ type="text"
8
+ name="fifu_input_alt_<?php echo $i; ?>"
9
+ placeholder="alt attribute (required)"
10
+ value="<?php echo $alt[$i]; ?>"
11
+ style="<?php echo $altWidth, $show_alt[$i] ?>" />
12
 
13
  <a id="fifu_link_<?php echo $i; ?>"
14
  class="button"
17
  style="<?php echo $show_link[$i] ?>" >x</a>
18
 
19
  <div id="fifu_image_<?php echo $i; ?>"
20
+ style="<?php echo $height, $margin, $show_image[$i] ?>
21
+ background:url('<?php echo $url[$i]; ?>') no-repeat center center;
22
+ background-size:cover;" >
23
  </div>
24
 
25
  <!-- show URL field and preview button if URL was not provided yet -->
26
 
27
  <input id="fifu_input_url_<?php echo $i; ?>"
28
+ type="text"
29
+ name="fifu_input_url_<?php echo $i; ?>"
30
+ placeholder="URL"
31
+ value="<?php echo $url[$i]; ?>"
32
+ style="<?php echo $width, $margin, $show_url[$i] ?>" />
33
 
34
  <a id="fifu_button_<?php echo $i; ?>"
35
  class="button"
admin/meta-box.php CHANGED
@@ -123,7 +123,7 @@ function fifu_save_properties($post_id) {
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
  }
123
 
124
  function fifu_update_or_delete($post_id, $field, $url) {
125
  if ($url)
126
+ update_post_meta($post_id, $field, fifu_convert($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.6.5
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://featuredimagefromurl.com/
9
  */
@@ -15,6 +15,7 @@ define('FIFU_ADMIN_DIR', FIFU_PLUGIN_DIR . '/admin');
15
  require_once( FIFU_INCLUDES_DIR . '/thumbnail.php' );
16
  require_once( FIFU_INCLUDES_DIR . '/thumbnail-category.php' );
17
  require_once( FIFU_INCLUDES_DIR . '/external-post.php' );
 
18
 
19
  if (is_admin()) {
20
  require_once( FIFU_ADMIN_DIR . '/meta-box.php' );
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.6
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://featuredimagefromurl.com/
9
  */
15
  require_once( FIFU_INCLUDES_DIR . '/thumbnail.php' );
16
  require_once( FIFU_INCLUDES_DIR . '/thumbnail-category.php' );
17
  require_once( FIFU_INCLUDES_DIR . '/external-post.php' );
18
+ require_once( FIFU_INCLUDES_DIR . '/convert-url.php' );
19
 
20
  if (is_admin()) {
21
  require_once( FIFU_ADMIN_DIR . '/meta-box.php' );
includes/convert-url.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function fifu_convert($url) {
4
+ if (fifu_from_google_drive($url))
5
+ return fifu_google_drive_url($url);
6
+
7
+ return $url;
8
+ }
9
+
10
+ //Google Drive
11
+
12
+ function fifu_from_google_drive($url) {
13
+ return strpos($url, 'drive.google.com') !== false;
14
+ }
15
+
16
+ function fifu_google_drive_id($url) {
17
+ preg_match("/[-\w]{25,}/", $url, $matches);
18
+ return $matches[0];
19
+ }
20
+
21
+ function fifu_google_drive_url($url) {
22
+ return 'https://drive.google.com/uc?id=' . fifu_google_drive_id($url);
23
+ }
includes/external-post.php CHANGED
@@ -32,7 +32,7 @@ function fifu_save_properties_ext($post_id) {
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', $url);
36
  }
37
 
38
  function fifu_first_img_in_content($content) {
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
  }
37
 
38
  function fifu_first_img_in_content($content) {
includes/html/js/image.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+ setTimeout(function () {
3
+ jQuery('div.flex-viewport').each(function (index) {
4
+ jQuery(this).css('height', '');
5
+ });
6
+ }, 500);
7
+ });
includes/html/script.html CHANGED
@@ -1 +1,2 @@
 
1
  <script><?php include 'js/jquery.lazyloadxt.extra.js' ?></script>
1
+ <script><?php include 'js/image.js' ?></script>
2
  <script><?php include 'js/jquery.lazyloadxt.extra.js' ?></script>
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, wp, rest, api, wp rest api, lazy, load
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
  Stable tag: 4.8
@@ -30,9 +30,11 @@ Features:
30
 
31
  * compatible with WP All Import plugin;
32
 
 
 
33
  * supports WP REST API (**premium feature**);
34
 
35
- * 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**);
36
 
37
  * you can use a slider of images as featured image (**premium feature**);
38
 
@@ -296,6 +298,9 @@ was removed. To finish, a Premium version is now been presented.
296
  = 1.6.5 =
297
  * Bug fix.
298
 
 
 
 
299
  == Upgrade Notice ==
300
 
301
  = 1.0 =
@@ -447,4 +452,7 @@ was removed. To finish, a Premium version is now been presented.
447
  * Bug fix.
448
 
449
  = 1.6.5 =
450
- * Bug fix.
 
 
 
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, lazy, load, google, drive
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
  Stable tag: 4.8
30
 
31
  * compatible with WP All Import plugin;
32
 
33
+ * some nonstandard image URLs, such as Google Drive's, will work as well;
34
+
35
  * supports WP REST API (**premium feature**);
36
 
37
+ * all features created for external images are available for external videos from YouTube and Vimeo. For YouTube videos, it's possible to set player parameters. And you can define the video size for each screen type (**premium feature**);
38
 
39
  * you can use a slider of images as featured image (**premium feature**);
40
 
298
  = 1.6.5 =
299
  * Bug fix.
300
 
301
+ = 1.6.6 =
302
+ * Support to Google Drive images.
303
+
304
  == Upgrade Notice ==
305
 
306
  = 1.0 =
452
  * Bug fix.
453
 
454
  = 1.6.5 =
455
+ * Bug fix.
456
+
457
+ = 1.6.6 =
458
+ * Support to Google Drive images.