Featured Image From URL - Version 2.9.3

Version Description

  • New feature: external images can be loaded from Unsplash (keywords search or randomly); New Premium feature: Unsplash Image Size; Improvement: lightbox on post editor; Bug fix: conflict with tagDiv Composer plugin.
Download this release

Release Info

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

Code changes from version 2.9.2 to 2.9.3

admin/category.php CHANGED
@@ -8,7 +8,6 @@ function fifu_ctgr_edit_box($term) {
8
  $width = 'width:100%;';
9
  $height = 'height:200px;';
10
  $align = 'text-align:left;';
11
- $show_news = 'display:none';
12
  $url = $alt = null;
13
 
14
  if (is_object($term)) {
@@ -33,7 +32,6 @@ function fifu_ctgr_add_box() {
33
  $width = 'width:100%;';
34
  $height = 'height:200px;';
35
  $align = 'text-align:left;';
36
- $show_news = 'display:none';
37
 
38
  $show_button = $url = $alt = '';
39
  $show_alt = $show_image = $show_link = 'display:none;';
8
  $width = 'width:100%;';
9
  $height = 'height:200px;';
10
  $align = 'text-align:left;';
 
11
  $url = $alt = null;
12
 
13
  if (is_object($term)) {
32
  $width = 'width:100%;';
33
  $height = 'height:200px;';
34
  $align = 'text-align:left;';
 
35
 
36
  $show_button = $url = $alt = '';
37
  $show_alt = $show_image = $show_link = 'display:none;';
admin/html/js/meta-box.js CHANGED
@@ -2,20 +2,56 @@ 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_button").show();
 
10
  }
11
 
12
  function previewImage() {
13
  var $url = jQuery("#fifu_input_url").val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  $url = fifu_convert($url);
15
 
 
 
16
  if ($url) {
17
  jQuery("#fifu_button").hide();
18
- jQuery("#fifu_news").hide();
19
 
20
  jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
21
 
@@ -34,3 +70,17 @@ function getMeta(url) {
34
  src: url
35
  });
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  jQuery("#fifu_input_alt").hide();
3
  jQuery("#fifu_image").hide();
4
  jQuery("#fifu_link").hide();
5
+ jQuery("#fifu_next").hide();
6
 
7
  jQuery("#fifu_input_alt").val("");
8
  jQuery("#fifu_input_url").val("");
9
 
10
  jQuery("#fifu_button").show();
11
+ jQuery("#fifu_help").show();
12
  }
13
 
14
  function previewImage() {
15
  var $url = jQuery("#fifu_input_url").val();
16
+
17
+ if (!$url.startsWith("http")) {
18
+ jQuery("#fifu_keywords").val($url);
19
+ jQuery('#fifu_button').block({message: '', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
20
+ var xhr = new XMLHttpRequest();
21
+ xhr.onreadystatechange = function (e) {
22
+ if (xhr.status == 200 && xhr.readyState == 4) {
23
+ if ($url != xhr.responseURL) {
24
+ $url = xhr.responseURL;
25
+ jQuery("#fifu_input_url").val($url);
26
+ runPreview($url);
27
+ jQuery("#fifu_next").hide();
28
+ if (jQuery("#fifu_input_url").val() && jQuery("#fifu_keywords").val())
29
+ jQuery('#fifu_next').parent().parent().block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
30
+ }
31
+ setTimeout(function () {
32
+ if (jQuery("#fifu_input_url").val() && jQuery("#fifu_keywords").val())
33
+ jQuery("#fifu_next").show();
34
+ jQuery('#fifu_next').parent().parent().unblock();
35
+ jQuery('#fifu_button').unblock();
36
+ }, 2000);
37
+ }
38
+ }
39
+ xhr.open("GET", 'https://source.unsplash.com/featured/?' + $url, true);
40
+ xhr.send();
41
+ } else {
42
+ jQuery("#fifu_next").hide();
43
+ runPreview($url);
44
+ }
45
+ }
46
+
47
+ function runPreview($url) {
48
  $url = fifu_convert($url);
49
 
50
+ jQuery("#fifu_lightbox").attr('href', $url);
51
+
52
  if ($url) {
53
  jQuery("#fifu_button").hide();
54
+ jQuery("#fifu_help").hide();
55
 
56
  jQuery("#fifu_image").css('background-image', "url('" + $url + "')");
57
 
70
  src: url
71
  });
72
  }
73
+
74
+ jQuery(document).ready(function () {
75
+ jQuery("#fifu_next").on('click', function (evt) {
76
+ evt.stopImmediatePropagation();
77
+ if (jQuery("#fifu_keywords").val()) {
78
+ jQuery("#fifu_input_url").val(jQuery("#fifu_keywords").val());
79
+ previewImage();
80
+ }
81
+ });
82
+ jQuery("#fifu_image").on('click', function (evt) {
83
+ evt.stopImmediatePropagation();
84
+ jQuery.fancybox.open('<img src="' + jQuery("#fifu_input_url").val() + '" style="max-height:600px">');
85
+ });
86
+ });
admin/html/menu.html CHANGED
@@ -563,6 +563,22 @@
563
  </div>
564
  </div>
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  <div class="box">
567
  <h2>Replace Broken Image</h2>
568
  <div class="greybox" id="grad2">
@@ -2759,6 +2775,19 @@
2759
  From September 2019, always you guys report an issue between FIFU and another plugin or theme, the solution will be posted here.
2760
  </div>
2761
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
2762
  <div class="box">
2763
  <table>
2764
  <tr>
563
  </div>
564
  </div>
565
 
566
+ <div class="box">
567
+ <h2>Unsplash Image Size (for Keyword Search and Random Image)</h2>
568
+ <div class="greybox" id="grad2">
569
+ <b>Premium feature</b><br><br>
570
+ Here you can define the size of the Unsplash images loaded (randomly or via keywords search) on post editor. Examples of valid sizes: 500x500, 300x400, 1920x1080... Or leave this field empty to get the original size.
571
+ </div>
572
+ <br>
573
+ <input id="fifu_input_unsplash_size"
574
+ type="text"
575
+ name="fifu_input_unsplash_size"
576
+ value=""
577
+ size="8">
578
+ <input type="submit"
579
+ value="Submit" disabled>
580
+ </div>
581
+
582
  <div class="box">
583
  <h2>Replace Broken Image</h2>
584
  <div class="greybox" id="grad2">
2775
  From September 2019, always you guys report an issue between FIFU and another plugin or theme, the solution will be posted here.
2776
  </div>
2777
  </div>
2778
+ <div class="box">
2779
+ <table>
2780
+ <tr>
2781
+ <td style="border-bottom:none">2020-02-27</td>
2782
+ <td style="border-bottom:none"><h3> Orienko</h3></td>
2783
+ <td style="border-bottom:none">theme</td>
2784
+ </tr>
2785
+ </table>
2786
+ <div class="greybox" style="position: relative; top: -10px">
2787
+ External videos are not being shown:<br>
2788
+ 1) enable "FIFU Settings > Admin > Internal URL Parameters".<br>
2789
+ </div>
2790
+ </div>
2791
  <div class="box">
2792
  <table>
2793
  <tr>
admin/html/meta-box.html CHANGED
@@ -19,13 +19,14 @@
19
  <div id="fifu_image"
20
  style="<?php echo $height, $margin, $show_image ?>
21
  background:url('<?php echo $url; ?>') no-repeat center center;
22
- background-size:cover;" >
 
23
  </div>
24
 
25
  <input id="fifu_input_url"
26
  type="text"
27
  name="fifu_input_url"
28
- placeholder="Image URL"
29
  value="<?php echo $url; ?>"
30
  style="<?php echo $width, $margin ?>" />
31
 
@@ -34,6 +35,12 @@
34
  href="#"
35
  onClick="removeImage();"
36
  style="<?php echo $show_link ?>" >remove external featured image</a>
 
 
 
 
 
 
37
  </center>
38
 
39
  <input
@@ -48,9 +55,28 @@
48
  name="fifu_input_image_height"
49
  value="" >
50
 
 
 
 
 
 
 
51
  <!-- show preview button if URL was not provided yet -->
52
 
53
  <a id="fifu_button"
54
  class="button"
55
  onClick="previewImage();"
56
  style="<?php echo $align, $margin, $show_button ?>" >Preview</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  <div id="fifu_image"
20
  style="<?php echo $height, $margin, $show_image ?>
21
  background:url('<?php echo $url; ?>') no-repeat center center;
22
+ background-size:cover;
23
+ cursor:zoom-in" >
24
  </div>
25
 
26
  <input id="fifu_input_url"
27
  type="text"
28
  name="fifu_input_url"
29
+ placeholder="Image URL or Keywords"
30
  value="<?php echo $url; ?>"
31
  style="<?php echo $width, $margin ?>" />
32
 
35
  href="#"
36
  onClick="removeImage();"
37
  style="<?php echo $show_link ?>" >remove external featured image</a>
38
+ <span
39
+ id="fifu_next"
40
+ class="dashicons dashicons-arrow-right-alt"
41
+ style="font-size:19px;position:relative;background-color:transparent;cursor:pointer;display:none"
42
+ title="Next">
43
+ </span>
44
  </center>
45
 
46
  <input
55
  name="fifu_input_image_height"
56
  value="" >
57
 
58
+ <input
59
+ type="hidden"
60
+ id="fifu_keywords"
61
+ name="fifu_keywords"
62
+ value="" >
63
+
64
  <!-- show preview button if URL was not provided yet -->
65
 
66
  <a id="fifu_button"
67
  class="button"
68
  onClick="previewImage();"
69
  style="<?php echo $align, $margin, $show_button ?>" >Preview</a>
70
+
71
+ <span id="fifu_help"
72
+ title="Example of
73
+ - image URL: http...
74
+ - keywords: sea,sun
75
+
76
+ To get a random image leave this field empty.
77
+
78
+ It's possible to define a size for the auto-generated images:
79
+ - Settings > Featured Image > Unsplash Image Sizes"
80
+ class="dashicons dashicons-editor-help"
81
+ style="<?php echo $show_button . ';float:right' ?>">
82
+ </span>
admin/meta-box.php CHANGED
@@ -25,6 +25,10 @@ function fifu_insert_meta_box() {
25
  add_action('add_meta_boxes', 'fifu_add_css');
26
 
27
  function fifu_add_css() {
 
 
 
 
28
  wp_register_style('featured-image-from-url', plugins_url('/html/css/editor.css', __FILE__));
29
  wp_enqueue_style('featured-image-from-url');
30
  }
@@ -34,13 +38,12 @@ function fifu_show_elements($post) {
34
  $width = 'width:100%;';
35
  $height = 'height:200px;';
36
  $align = 'text-align:left;';
37
- $show_news = 'display:inline';
38
 
39
  $url = get_post_meta($post->ID, 'fifu_image_url', true);
40
  $alt = get_post_meta($post->ID, 'fifu_image_alt', true);
41
 
42
  if ($url) {
43
- $show_button = $show_news = 'display:none;';
44
  $show_alt = $show_image = $show_link = '';
45
  } else {
46
  $show_alt = $show_image = $show_link = 'display:none;';
25
  add_action('add_meta_boxes', 'fifu_add_css');
26
 
27
  function fifu_add_css() {
28
+ wp_enqueue_script('jquery-block-ui', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js');
29
+ wp_enqueue_style('fancy-box-css', 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.css');
30
+ wp_enqueue_script('fancy-box-js', 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js');
31
+
32
  wp_register_style('featured-image-from-url', plugins_url('/html/css/editor.css', __FILE__));
33
  wp_enqueue_style('featured-image-from-url');
34
  }
38
  $width = 'width:100%;';
39
  $height = 'height:200px;';
40
  $align = 'text-align:left;';
 
41
 
42
  $url = get_post_meta($post->ID, 'fifu_image_url', true);
43
  $alt = get_post_meta($post->ID, 'fifu_image_alt', true);
44
 
45
  if ($url) {
46
+ $show_button = 'display:none;';
47
  $show_alt = $show_image = $show_link = '';
48
  } else {
49
  $show_alt = $show_image = $show_link = 'display:none;';
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 your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
7
- * Version: 2.9.2
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://fifu.app/
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: 2.9.3
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
includes/attachment.php CHANGED
@@ -79,8 +79,8 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
79
  $arrFIFU = fifu_get_width_height($dimension);
80
  return array(
81
  fifu_has_internal_image_path($image[0]) ? get_post($att_id)->guid : $image[0],
82
- !$dimension && isset($image_size['width']) && $image_size['width'] < $arrFIFU['width'] ? $image_size['width'] : $arrFIFU['width'],
83
- !$dimension && isset($image_size['height']) && $image_size['height'] < $arrFIFU['height'] ? $image_size['height'] : $arrFIFU['height'],
84
  isset($image_size['crop']) ? $image_size['crop'] : '',
85
  );
86
  }
79
  $arrFIFU = fifu_get_width_height($dimension);
80
  return array(
81
  fifu_has_internal_image_path($image[0]) ? get_post($att_id)->guid : $image[0],
82
+ $arrFIFU['width'] == null || (!$dimension && isset($image_size['width']) && $image_size['width'] < $arrFIFU['width']) ? $image_size['width'] : $arrFIFU['width'],
83
+ $arrFIFU['height'] == null || (!$dimension && isset($image_size['height']) && $image_size['height'] < $arrFIFU['height']) ? $image_size['height'] : $arrFIFU['height'],
84
  isset($image_size['crop']) ? $image_size['crop'] : '',
85
  );
86
  }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://donorbox.org/fifu
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, instagram, validation, jetpack, visual composer, play, pause, crop, resize, zoom, enable, disable, default, automatic, auto set, cloudinary, schedule, event, cron, seo, variable, tumblr, variation, product variation, shortcode, facebook, instagram, imgur, 9gag, wcfm, add-on, scraper
5
  Requires at least: 4.0
6
  Tested up to: 5.4
7
- Stable tag: 2.9.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -16,6 +16,8 @@ Features:
16
 
17
  * Featured Image from URL plugin allows you to use an external image as Featured Image of your post, page and Custom Post Type, such as WooCommerce Product;
18
 
 
 
19
  * perfect for external posts, the plugin is able to use the first (or nth) image/video as Featured Image;
20
 
21
  * when you access the table of posts/pages/products/categories in admin menu, the Featured Images are shown in a new column;
@@ -60,7 +62,9 @@ Features:
60
 
61
  * auto play/pause videos on mouse over/out (**premium feature**);
62
 
63
- * replace broken URLs by a default one (**premium feature**);
 
 
64
 
65
  **<a href="https://fifu.app/">Official Site</a>**
66
  **<a href="https://chrome.google.com/webstore/detail/fifu-scraper/pccimcccbkdeeadhejdmnffmllpicola">Google Chrome Extension</a>**
@@ -158,6 +162,9 @@ Features:
158
 
159
  == Changelog ==
160
 
 
 
 
161
  = 2.9.2 =
162
  * Bug fix: internal images were not being shown when used into Featured Image from URL field.
163
 
@@ -704,6 +711,9 @@ was removed. To finish, a Premium version is now been presented.
704
 
705
  == Upgrade Notice ==
706
 
 
 
 
707
  = 2.9.2 =
708
  * Bug fix: internal images were not being shown when used into Featured Image from URL field.
709
 
1
  === Plugin Name ===
2
  Contributors: marceljm
3
  Donate link: https://donorbox.org/fifu
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, instagram, validation, jetpack, visual composer, play, pause, crop, resize, zoom, enable, disable, default, automatic, auto set, cloudinary, schedule, event, cron, seo, variable, tumblr, variation, product variation, shortcode, facebook, instagram, imgur, 9gag, wcfm, add-on, scraper, 特色圖片, 网址, 外部, unsplash, keyword, random, acf
5
  Requires at least: 4.0
6
  Tested up to: 5.4
7
+ Stable tag: 2.9.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
16
 
17
  * Featured Image from URL plugin allows you to use an external image as Featured Image of your post, page and Custom Post Type, such as WooCommerce Product;
18
 
19
+ * integrated with Unsplash engine, allows to search images by keywords (or you can use random images);
20
+
21
  * perfect for external posts, the plugin is able to use the first (or nth) image/video as Featured Image;
22
 
23
  * when you access the table of posts/pages/products/categories in admin menu, the Featured Images are shown in a new column;
62
 
63
  * auto play/pause videos on mouse over/out (**premium feature**);
64
 
65
+ * replaces broken URLs by a default one (**premium feature**);
66
+
67
+ * defines Unsplash image sizes (**premium feature**).
68
 
69
  **<a href="https://fifu.app/">Official Site</a>**
70
  **<a href="https://chrome.google.com/webstore/detail/fifu-scraper/pccimcccbkdeeadhejdmnffmllpicola">Google Chrome Extension</a>**
162
 
163
  == Changelog ==
164
 
165
+ = 2.9.3 =
166
+ * New feature: external images can be loaded from Unsplash (keywords search or randomly); New Premium feature: Unsplash Image Size; Improvement: lightbox on post editor; Bug fix: conflict with tagDiv Composer plugin.
167
+
168
  = 2.9.2 =
169
  * Bug fix: internal images were not being shown when used into Featured Image from URL field.
170
 
711
 
712
  == Upgrade Notice ==
713
 
714
+ = 2.9.3 =
715
+ * New feature: external images can be loaded from Unsplash (keywords search or randomly); New Premium feature: Unsplash Image Size; Improvement: lightbox on post editor; Bug fix: conflict with tagDiv Composer plugin.
716
+
717
  = 2.9.2 =
718
  * Bug fix: internal images were not being shown when used into Featured Image from URL field.
719