Featured Image From URL - Version 1.4.3

Version Description

  • Full integration with Sirv plugin.

=

Download this release

Release Info

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

Code changes from version 1.4.2 to 1.4.3

featured-image-from-url.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * Description: Allows to use an external image as Featured Image of your post, page or Custom Post Type, such as WooCommerce Product (supports Product Gallery also).
6
- * Version: 1.4.2
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://marceljm.com/wordpress/featured-image-from-url-premium/
9
  */
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * Description: Allows to use an external image as Featured Image of your post, page or Custom Post Type, such as WooCommerce Product (supports Product Gallery also).
6
+ * Version: 1.4.3
7
  * Author: Marcel Jacques Machado
8
  * Author URI: http://marceljm.com/wordpress/featured-image-from-url-premium/
9
  */
includes/thumbnail.php CHANGED
@@ -3,70 +3,76 @@
3
  add_filter('wp_head', 'fifu_add_social_tags');
4
 
5
  function fifu_add_social_tags() {
6
- $post_id = get_the_ID();
7
- $url = get_post_meta($post_id, 'fifu_image_url', true);
8
- $title = get_the_title($post_id);
9
- $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
10
 
11
- if ($url)
12
- include 'html/social.html';
 
 
 
13
  }
14
 
15
  add_action('the_post', 'fifu_choose');
16
 
17
  function fifu_choose($post) {
18
- $post_id = $post->ID;
19
 
20
- $image_url = get_post_meta($post_id, 'fifu_image_url', true);
21
 
22
- $featured_image = get_post_meta($post_id, '_thumbnail_id', true);
23
 
24
- if ($image_url) {
25
- if (!$featured_image)
26
- update_post_meta($post_id, '_thumbnail_id', -1);
27
- }
28
- else {
29
- if ($featured_image == -1)
30
- delete_post_meta($post_id, '_thumbnail_id');
31
- }
32
  }
33
 
34
  add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
35
 
36
  function fifu_replace($html, $post_id) {
37
- $url = get_post_meta($post_id, 'fifu_image_url', true);
38
- $alt = get_post_meta($post_id, 'fifu_image_alt', true);
39
 
40
- if ($url)
41
- $html = fifu_get_html($url, $alt);
42
 
43
- return $html;
44
  }
45
 
46
  function fifu_get_html($url, $alt) {
47
- return sprintf('<!-- Featured Image From URL plugin --> <img src="%s" alt="%s"></img>', $url, $alt);
 
 
 
48
  }
49
 
50
  add_filter('the_content', 'fifu_add_to_content');
51
 
52
  function fifu_add_to_content($content) {
53
- if (is_singular() && has_post_thumbnail() && get_option('fifu_content') == 'toggleon')
54
- return get_the_post_thumbnail() . $content;
55
- else
56
- return $content;
57
  }
58
 
59
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
60
 
61
  function fifu_replace_attachment_url($att_url, $att_id) {
62
- if (get_option('fifu_attachment_id') == $att_id) {
63
- if (is_admin())
64
- $att_url = '/wp-content/plugins/featured-image-from-url/admin/images/fifu-text.jpg';
65
- else {
66
- $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
67
- if ($url)
68
- $att_url = $url;
69
- }
70
- }
71
- return $att_url;
72
  }
3
  add_filter('wp_head', 'fifu_add_social_tags');
4
 
5
  function fifu_add_social_tags() {
6
+ $post_id = get_the_ID();
7
+ $url = get_post_meta($post_id, 'fifu_image_url', true);
8
+ $title = get_the_title($post_id);
9
+ $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
10
 
11
+ if ($url)
12
+ include 'html/social.html';
13
+
14
+ if (is_plugin_active('sirv/sirv.php'))
15
+ include 'html/sirv.html';
16
  }
17
 
18
  add_action('the_post', 'fifu_choose');
19
 
20
  function fifu_choose($post) {
21
+ $post_id = $post->ID;
22
 
23
+ $image_url = get_post_meta($post_id, 'fifu_image_url', true);
24
 
25
+ $featured_image = get_post_meta($post_id, '_thumbnail_id', true);
26
 
27
+ if ($image_url) {
28
+ if (!$featured_image)
29
+ update_post_meta($post_id, '_thumbnail_id', -1);
30
+ }
31
+ else {
32
+ if ($featured_image == -1)
33
+ delete_post_meta($post_id, '_thumbnail_id');
34
+ }
35
  }
36
 
37
  add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
38
 
39
  function fifu_replace($html, $post_id) {
40
+ $url = get_post_meta($post_id, 'fifu_image_url', true);
41
+ $alt = get_post_meta($post_id, 'fifu_image_alt', true);
42
 
43
+ if ($url)
44
+ $html = fifu_get_html($url, $alt);
45
 
46
+ return $html;
47
  }
48
 
49
  function fifu_get_html($url, $alt) {
50
+ if (is_plugin_active('sirv/sirv.php') && strpos($url, "sirv.com") !== false)
51
+ return sprintf('<!-- Featured Image From URL plugin --> <img class="Sirv" data-src="%s"></img>', $url);
52
+
53
+ return sprintf('<!-- Featured Image From URL plugin --> <img src="%s" alt="%s"></img>', $url, $alt);
54
  }
55
 
56
  add_filter('the_content', 'fifu_add_to_content');
57
 
58
  function fifu_add_to_content($content) {
59
+ if (is_singular() && has_post_thumbnail() && get_option('fifu_content') == 'toggleon')
60
+ return get_the_post_thumbnail() . $content;
61
+ else
62
+ return $content;
63
  }
64
 
65
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
66
 
67
  function fifu_replace_attachment_url($att_url, $att_id) {
68
+ if (get_option('fifu_attachment_id') == $att_id) {
69
+ if (is_admin())
70
+ $att_url = '/wp-content/plugins/featured-image-from-url/admin/images/fifu-text.jpg';
71
+ else {
72
+ $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
73
+ if ($url)
74
+ $att_url = $url;
75
+ }
76
+ }
77
+ return $att_url;
78
  }
readme.txt CHANGED
@@ -247,6 +247,9 @@ was removed. To finish, a Premium version is now been presented.
247
  = 1.4.2 =
248
  * CSS style.
249
 
 
 
 
250
  == Upgrade Notice ==
251
 
252
  = 1.0 =
@@ -330,3 +333,6 @@ was removed. To finish, a Premium version is now been presented.
330
 
331
  = 1.4.2 =
332
  * CSS style.
 
 
 
247
  = 1.4.2 =
248
  * CSS style.
249
 
250
+ = 1.4.3 =
251
+ * Full integration with Sirv plugin.
252
+
253
  == Upgrade Notice ==
254
 
255
  = 1.0 =
333
 
334
  = 1.4.2 =
335
  * CSS style.
336
+
337
+ = 1.4.3 =
338
+ * Full integration with Sirv plugin.