Featured Image From URL - Version 1.0.1

Version Description

Download this release

Release Info

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

Version 1.0.1

admin/html/css/menu.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wrap {
2
+ max-width: 800px;
3
+ margin: 20px 20px 20px 15px;
4
+ }
5
+
6
+ .box {
7
+ margin: 20px 0 0;
8
+ background: #fff;
9
+ border: 1px solid #dbdbdb;
10
+ padding: 20px;
11
+ }
12
+
13
+ .greybox {
14
+ margin: 10px 0 0;
15
+ background: #f9f9f9;
16
+ border: 1px solid #dbdbdb;
17
+ padding: 20px;
18
+ }
19
+
20
+ .greybox p {
21
+ font-style: italic;
22
+ color: #999;
23
+ }
24
+
25
+ .toggleon, .toggleoff {
26
+ padding: 0;
27
+ overflow: hidden;
28
+ width: 72px;
29
+ height: 24px;
30
+ background: url("<?php echo $image_button ?>") 0 0 no-repeat;
31
+ text-align: center !important;
32
+ }
33
+
34
+ .toggleoff {
35
+ background: url("<?php echo $image_button ?>") -72px 0 no-repeat;
36
+ }
admin/html/js/menu.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function invert() {
2
+ if (jQuery("#fifu_toggle").attr("class") == "toggleon") {
3
+ jQuery("#fifu_toggle").attr("class", "toggleoff");
4
+ jQuery("#fifu_input_backlink").val(0);
5
+ }
6
+ else {
7
+ jQuery("#fifu_toggle").attr("class", "toggleon");
8
+ jQuery("#fifu_input_backlink").val(1);
9
+ }
10
+ }
11
+
12
+ jQuery(function () {
13
+ var url = window.location.href;
14
+
15
+ jQuery("#fifu_form").submit(function () {
16
+
17
+ var frm = jQuery("#fifu_form");
18
+
19
+ jQuery.ajax({
20
+ type: frm.attr('method'),
21
+ url: url,
22
+ data: frm.serialize(),
23
+ success: function (data) {
24
+ //alert('saved');
25
+ }
26
+ });
27
+ });
28
+ });
admin/html/js/meta-box.js ADDED
@@ -0,0 +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
+ }
admin/html/menu.html ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style><?php include 'css/menu.css' ?></style>
2
+
3
+ <script><?php include 'js/menu.js' ?></script>
4
+
5
+ <div class="wrap">
6
+
7
+ <div class="box">
8
+
9
+ <h2>Featured Image From URL</h2>
10
+
11
+ <div class="greybox">
12
+
13
+ <p>This plugin allows you to use an external image as Featured Image of your post or page. For more information, refer to <a href="http://marceljm.com/wordpress/featured-image-from-url/" target="_blank">Featured Image From URL</a>. </p>
14
+
15
+ </div>
16
+
17
+ </div>
18
+
19
+ <div class="box">
20
+
21
+ <h2>Make a Donation</h2>
22
+
23
+ <div class="greybox">
24
+
25
+ <p>Featured Image From URL is completely free and without advertising. To help me to continue updating and improving it, please consider making a donation by <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG" target="_blank">PayPal</a>. Thank you!</p>
26
+
27
+ </div>
28
+
29
+ </div>
30
+
31
+ <div class="box">
32
+
33
+ <h2>Suggestions For Improvement</h2>
34
+
35
+ <div class="greybox">
36
+
37
+ <p>Constructive suggestions for improvement are always welcome. Just send an email to <a href="mailto:contact@marceljm.com">contact@marceljm.com</a>. Your request can be available in next version.</p>
38
+
39
+ </div>
40
+
41
+ </div>
42
+
43
+ <div class="box">
44
+
45
+ <h2>Give This Plugin a 5-Star Rating</h2>
46
+
47
+ <div class="greybox">
48
+
49
+ <p>Do you really love Featured Image From URL? So give your <a href="https://wordpress.org/plugins/featured-image-from-url" target="_blank">rating</a> right now. It's very important for me and WordPress community too.</p>
50
+
51
+ </div>
52
+
53
+ </div>
54
+
55
+ <div class="box">
56
+
57
+ <h2>Backlink to Featured Image From URL</h2>
58
+
59
+ <div class="greybox">
60
+
61
+ <p>Do you mind if I put a invisible and not clickable backlink in your page/post? Just Googlebot will be able to see (but not follow) that. This may seem very simple but increases the plugin page position on Google without interfering with your site layout, performance or SEO : )</p>
62
+
63
+ </div>
64
+
65
+ <p/>
66
+
67
+ <form
68
+ id="fifu_form"
69
+ action="javascript:void(0)"
70
+ method="post">
71
+
72
+ <input
73
+ type="image"
74
+ href="javascript:void(0)"
75
+ id="fifu_toggle"
76
+ onclick="invert()"
77
+ name="fifu_toggle"
78
+ class="<?php echo $enable; ?>"
79
+ value=" ">
80
+
81
+ <input
82
+ type="hidden"
83
+ id="fifu_input_backlink"
84
+ name="fifu_input_backlink"
85
+ value="" >
86
+ </form>
87
+
88
+ </div>
89
+
90
+ <div class="box">
91
+
92
+ <h2>About The Author</h2>
93
+
94
+ <div class="greybox">
95
+
96
+ <p>Hi! I'm Marcel Jacques Machado. Graduated in Computer Science, I work as a Software Engineer for almost a decade. I already worked with C, Python, Delphi, Shell Script and other programming languages and technologies. Nowadays, I develop web services for MasterCard in Brazil using Java. About PHP, this plugin, Featured Image From URL, is my first pratical experience. I also have a <a href="http://marceljm.com/" target="_blank">blog</a> in WordPress and I expect to post some useful content very soon.
97
+
98
+ </div>
99
+
100
+ </div>
101
+
102
+ </div>
admin/html/meta-box.html ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script><?php include 'js/meta-box.js' ?></script>
2
+
3
+ <!-- show alt field, image and remove link if URL was already provided -->
4
+
5
+ <input id="fifu_input_alt"
6
+ type="text"
7
+ name="fifu_input_alt"
8
+ placeholder="alt attribute (optional)"
9
+ value="<?php echo $alt; ?>"
10
+ style="<?php echo $width, $margin, $show_alt ?>" />
11
+
12
+ <div id="fifu_image"
13
+ style="<?php echo $height, $margin, $show_image ?>
14
+ background:url('<?php echo $url; ?>') no-repeat center center;
15
+ background-size:cover;" >
16
+ </div>
17
+
18
+ <p/>
19
+
20
+ <a id="fifu_link"
21
+ href="#"
22
+ onClick="removeImage();"
23
+ style="<?php echo $show_link ?>" >Remove external featured image</a>
24
+
25
+ <!-- show URL field and preview button if URL was not provided yet -->
26
+
27
+ <input id="fifu_input_url"
28
+ type="text"
29
+ name="fifu_input_url"
30
+ placeholder="URL"
31
+ value="<?php echo $url; ?>"
32
+ style="<?php echo $width, $margin, $show_url ?>" />
33
+
34
+ <a id="fifu_button"
35
+ class="button"
36
+ onClick="previewImage();"
37
+ style="<?php echo $align, $margin, $show_button ?>" >Preview</a>
admin/images/favicon.png ADDED
Binary file
admin/images/onoff.jpg ADDED
Binary file
admin/menu.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action('admin_menu', 'fifu_insert_menu');
4
+
5
+ function fifu_insert_menu() {
6
+ add_menu_page(
7
+ 'Featured Image From URL',
8
+ 'Featured Image From URL',
9
+ 'administrator',
10
+ 'featured-image-from-url',
11
+ 'fifu_get_menu_html',
12
+ plugins_url() . '/featured-image-from-url/admin/images/favicon.png'
13
+ );
14
+
15
+ add_action('admin_init', 'fifu_get_menu_settings');
16
+ }
17
+
18
+ function fifu_get_menu_html() {
19
+ $image_button = plugins_url() . '/featured-image-from-url/admin/images/onoff.jpg';
20
+
21
+ $enable = get_option('fifu_backlink');
22
+
23
+ include 'html/menu.html';
24
+
25
+ if ((int) $_POST['fifu_input_backlink'])
26
+ update_option('fifu_backlink', 'toggleon');
27
+ else
28
+ update_option('fifu_backlink', 'toggleoff');
29
+ }
30
+
31
+ function fifu_get_menu_settings() {
32
+ register_setting('settings-group', 'fifu_backlink');
33
+
34
+ if (!get_option('fifu_backlink'))
35
+ update_option('fifu_backlink', 'toggleoff');
36
+ }
37
+
admin/meta-box.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action('add_meta_boxes', 'fifu_insert_meta_box');
4
+
5
+ function fifu_insert_meta_box() {
6
+ $post_types = array('post', 'page');
7
+
8
+ foreach ($post_types as $post_type) {
9
+ add_meta_box(
10
+ 'Url Meta Box',
11
+ 'External Featured Image',
12
+ 'fifu_show_elements',
13
+ $post_type,
14
+ 'side',
15
+ 'default'
16
+ );
17
+ }
18
+ }
19
+
20
+ function fifu_show_elements($post) {
21
+ $url = get_post_meta($post->ID, 'fifu_image_url', true);
22
+ $alt = get_post_meta($post->ID, 'fifu_image_alt', true);
23
+
24
+ if ($url)
25
+ $show_url = $show_button = 'display:none;';
26
+ else
27
+ $show_alt = $show_image = $show_link = 'display:none;';
28
+
29
+ $margin = 'margin-top:10px;';
30
+ $width = 'width:100%;';
31
+ $height = 'height:266px;';
32
+ $align = 'text-align:left;';
33
+
34
+ include 'html/meta-box.html';
35
+ }
36
+
37
+ add_action('save_post', 'fifu_save_image_properties');
38
+
39
+ function fifu_save_image_properties($post_id) {
40
+ if (isset($_POST['fifu_input_url']))
41
+ update_post_meta($post_id, 'fifu_image_url', esc_url($_POST['fifu_input_url']));
42
+
43
+ if (isset($_POST['fifu_input_alt']))
44
+ update_post_meta($post_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
45
+ }
46
+
featured-image-from-url.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Plugin Name: Featured Image From URL
5
+ * Description: Allows you to use an external image as Featured Image of your post or page.
6
+ * Version: 1.0
7
+ * Author: Marcel Jacques Machado
8
+ * Author URI: http://marceljm.com
9
+ */
10
+
11
+ define('FIFU_PLUGIN_DIR', plugin_dir_path(__FILE__));
12
+ define('FIFU_INCLUDES_DIR', FIFU_PLUGIN_DIR . '/includes');
13
+ define('FIFU_ADMIN_DIR', FIFU_PLUGIN_DIR . '/admin');
14
+
15
+ require_once( FIFU_INCLUDES_DIR . '/thumbnail.php' );
16
+ if (is_admin()) {
17
+ require_once( FIFU_ADMIN_DIR . '/meta-box.php' );
18
+ require_once( FIFU_ADMIN_DIR . '/menu.php' );
19
+ }
includes/html/backlink.html ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <a
2
+ rel="nofollow"
3
+ href="http://marceljm.com/featured-image-from-url/"
4
+ style="display:none;">
5
+ Featured Image From URL is a WordPress plugin developed by marceljm.
6
+ </a>
includes/html/social.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <meta
2
+ property="og:image"
3
+ content="<?php echo $image_url; ?>"
4
+ />
5
+
6
+ <meta
7
+ name="twitter:image"
8
+ content="<?php echo $image_url; ?>"
9
+ />
includes/html/thumbnail.html ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <!-- Featured Image from URL: http://marceljm.com/featured-image-from-url/ -->
2
+ <img
3
+ src="<?php echo $image_url; ?>"
4
+ alt="<?php echo $alt; ?>" >
5
+ </img>
includes/thumbnail.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter('wp_head', 'fifu_image_social_tags');
4
+
5
+ function fifu_image_social_tags() {
6
+ $post_id = get_the_ID();
7
+
8
+ $image_url = get_post_meta($post_id, 'fifu_image_url', true);
9
+
10
+ if ($image_url)
11
+ include 'html/social.html';
12
+ }
13
+
14
+ add_action('the_post', 'fifu_choose');
15
+
16
+ function fifu_choose($post) {
17
+ $post_id = $post->ID;
18
+
19
+ $image_url = get_post_meta($post_id, 'fifu_image_url', true);
20
+
21
+ $featured_image = get_post_meta($post_id, '_thumbnail_id', true);
22
+
23
+ if ($image_url) {
24
+ if (!$featured_image)
25
+ update_post_meta($post_id, '_thumbnail_id', -1);
26
+ }
27
+ else {
28
+ if ($featured_image == -1)
29
+ delete_post_meta($post_id, '_thumbnail_id');
30
+ }
31
+ }
32
+
33
+ add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
34
+
35
+ function fifu_replace($html, $post_id) {
36
+ $image_url = get_post_meta($post_id, 'fifu_image_url', true);
37
+
38
+ if ($image_url) {
39
+ $html = fifu_get_html($post_id, $image_url);
40
+ if (get_option('fifu_backlink') == 'toggleon')
41
+ include 'html/backlink.html';
42
+ }
43
+
44
+ return $html;
45
+ }
46
+
47
+ function fifu_get_html($id, $image_url) {
48
+ $alt = get_post_meta($id, 'fifu_image_alt', true);
49
+ include 'html/thumbnail.html';
50
+ }
51
+
readme.txt ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, from, url, flickr
5
+ Requires at least: 4.0
6
+ Tested up to: 4.3.1
7
+ Stable tag: 4.3
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Allows you to use an external image as Featured Image of your post or page.
12
+
13
+ == Description ==
14
+
15
+ Allows you to use an external image (from Flickr, Picasa, Amazon S3, anywhere etc) as Featured Image of your post or page.
16
+
17
+ == Installation ==
18
+
19
+ 1. Install automatically or by uploading the ZIP file.
20
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
21
+ 1. The plugin settings will be immediately below or above the traditional "Featured Image" box, in the page/post editor.
22
+
23
+ == Frequently Asked Questions ==
24
+
25
+ = Where are the "Featured Image from URL" box? =
26
+
27
+ * It will be immediately below or above the traditional "Featured Image" box, in the page/post editor.
28
+
29
+ = What's the URL field? =
30
+
31
+ * There you should paste the image URL. For example: https://marceljm.com/wp-content/uploads/logo.png
32
+
33
+ = What's the preview button? =
34
+
35
+ * This button will show you a preview of the external image.
36
+
37
+ = Why don't I see the image preview? =
38
+
39
+ * Because your URL is invalid.
40
+
41
+ = What's the "alt attribute" field? =
42
+
43
+ * There you can write a short description of the image. It is optional.
44
+
45
+ = What's the "Remove external featured image" link? =
46
+
47
+ * It's used to remove the external image.
48
+
49
+ = What happens if I have two featured images (internal and external)? =
50
+
51
+ * The external image has priority in this case and the internal image won't be showed.
52
+
53
+ == Screenshots ==
54
+
55
+ 1. This plugin allows you to use an external image as Featured Image of your posts or pages. Just fill the URL field with the image address and click on preview button.
56
+
57
+ 2. If the URL is correct, the image preview will be shown. Then you can define the image title, filling the ALT field.
58
+
59
+ 3. The external image will be displayed with your post description.
60
+
61
+ 4. The external image will be displayed on your post or page.
62
+
63
+ 5. The external image will be displayed when someone shares your post or page on social networks.
64
+
65
+ == Changelog ==
66
+
67
+ = 1.0 =
68
+ * It's the first and only version.
69
+
70
+ == Upgrade Notice ==
71
+
72
+ = 1.0 =
73
+ * No upgraded yet.