Version Description
- Back to the version 1.9.1.
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 1.9.5 |
Comparing to | |
See all releases |
Code changes from version 1.9.4 to 1.9.5
- admin/html/css/menu.css +0 -3
- admin/html/js/menu.js +0 -8
- admin/html/menu.html +4 -16
- admin/html/meta-box.html +4 -4
- admin/menu.php +49 -73
- featured-image-from-url.php +1 -34
- includes/external-post.php +2 -63
- includes/html/js/image.js +0 -13
- includes/thumbnail.php +37 -69
- readme.txt +6 -0
admin/html/css/menu.css
CHANGED
@@ -29,8 +29,6 @@
|
|
29 |
height: 24px;
|
30 |
background: url("<?php echo $image_button ?>") 0 0 no-repeat;
|
31 |
text-align: center !important;
|
32 |
-
position: relative;
|
33 |
-
top: 5px;
|
34 |
}
|
35 |
|
36 |
.toggleoff {
|
@@ -53,7 +51,6 @@ th, td {
|
|
53 |
border-bottom: 1px solid #ddd;
|
54 |
padding-right: 32px;
|
55 |
font-weight: normal;
|
56 |
-
font-size: 12px;
|
57 |
}
|
58 |
|
59 |
th {
|
29 |
height: 24px;
|
30 |
background: url("<?php echo $image_button ?>") 0 0 no-repeat;
|
31 |
text-align: center !important;
|
|
|
|
|
32 |
}
|
33 |
|
34 |
.toggleoff {
|
51 |
border-bottom: 1px solid #ddd;
|
52 |
padding-right: 32px;
|
53 |
font-weight: normal;
|
|
|
54 |
}
|
55 |
|
56 |
th {
|
admin/html/js/menu.js
CHANGED
@@ -42,11 +42,3 @@ function save(formName, url) {
|
|
42 |
}
|
43 |
});
|
44 |
}
|
45 |
-
|
46 |
-
jQuery(function () {
|
47 |
-
jQuery('#fifu_toggle_fake').click(function () {
|
48 |
-
setTimeout(function () {
|
49 |
-
window.location.replace('admin.php?page=featured-image-from-url&fake=on');
|
50 |
-
}, 250);
|
51 |
-
});
|
52 |
-
});
|
42 |
}
|
43 |
});
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/html/menu.html
CHANGED
@@ -8,14 +8,6 @@
|
|
8 |
<h1>Featured Image From URL</h1>
|
9 |
</div>
|
10 |
|
11 |
-
<div class="box">
|
12 |
-
<h2 style="color:red">IMPORTANT!!!</h2>
|
13 |
-
<div class="greybox">
|
14 |
-
FIFU 2 is coming soon with some great improvements to solve problems as image size and image missing in some site areas.
|
15 |
-
<b>If your external images are not being shown after the last update</b>, try to disable/enable the toggle <a href="admin.php?page=featured-image-from-url#fake">Fake Internal Featured Image</a>. And if that doesn't solve your issue, please report that to the support email bellow. You can also go back to the <a href="https://downloads.wordpress.org/plugin/featured-image-from-url.1.9.1.zip">last stable version</a>.
|
16 |
-
</div>
|
17 |
-
</div>
|
18 |
-
|
19 |
<div class="box">
|
20 |
<h2>Help</h2>
|
21 |
<div class="greybox">
|
@@ -151,6 +143,8 @@
|
|
151 |
<div class="greybox" id="grad1">
|
152 |
Here you can define a CSS style to be applied to all external featured images. Usage example:<br><br>
|
153 |
width: 100%; border-radius: 8px; border: 1px solid #ddd; padding: 5px;
|
|
|
|
|
154 |
</div>
|
155 |
<br>
|
156 |
<form
|
@@ -191,12 +185,10 @@
|
|
191 |
</form>
|
192 |
</div>
|
193 |
|
194 |
-
<a name="fake"></a>
|
195 |
-
|
196 |
<div class="box">
|
197 |
<h2>Fake Internal Featured Image</h2>
|
198 |
<div class="greybox" id="grad1">
|
199 |
-
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.
|
200 |
</div>
|
201 |
<p/>
|
202 |
<form
|
@@ -417,14 +409,10 @@
|
|
417 |
</form>
|
418 |
</div>
|
419 |
|
420 |
-
<a name="lightbox"></a>
|
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.
|
426 |
-
<br><br>
|
427 |
-
<i>If this new FREE feature is useful to you, please cherish my work. Give FIFU a <a href="https://wordpress.org/support/view/plugin-reviews/featured-image-from-url?filter=5" target="_blank">5-star</a> rating!</i>
|
428 |
</div>
|
429 |
<br>
|
430 |
<table style="text-align:left">
|
8 |
<h1>Featured Image From URL</h1>
|
9 |
</div>
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
<div class="box">
|
12 |
<h2>Help</h2>
|
13 |
<div class="greybox">
|
143 |
<div class="greybox" id="grad1">
|
144 |
Here you can define a CSS style to be applied to all external featured images. Usage example:<br><br>
|
145 |
width: 100%; border-radius: 8px; border: 1px solid #ddd; padding: 5px;
|
146 |
+
<br><br>
|
147 |
+
<i>If this new FREE feature is useful to you, please cherish my work. Give FIFU a <a href="https://wordpress.org/support/view/plugin-reviews/featured-image-from-url?filter=5" target="_blank">5-star</a> rating!</i>
|
148 |
</div>
|
149 |
<br>
|
150 |
<form
|
185 |
</form>
|
186 |
</div>
|
187 |
|
|
|
|
|
188 |
<div class="box">
|
189 |
<h2>Fake Internal Featured Image</h2>
|
190 |
<div class="greybox" id="grad1">
|
191 |
+
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.
|
192 |
</div>
|
193 |
<p/>
|
194 |
<form
|
409 |
</form>
|
410 |
</div>
|
411 |
|
|
|
|
|
412 |
<div class="box">
|
413 |
<h2>WooCommerce</h2>
|
414 |
<div class="greybox" id="grad1">
|
415 |
+
You can disable the product lightbox and zoom here once these features are only compatible with the premium version.
|
|
|
|
|
416 |
</div>
|
417 |
<br>
|
418 |
<table style="text-align:left">
|
admin/html/meta-box.html
CHANGED
@@ -50,18 +50,18 @@
|
|
50 |
<div style="<?php echo $show_news ?>">
|
51 |
<br>
|
52 |
<hr>
|
53 |
-
<p style="font-size: 12px; padding: 5px; border-left: 6px solid black; color: black;
|
54 |
-
background-color: #eee; border-radius: 25px 5px;">New: WooCommerce <b><a href="admin.php?page=featured-image-from-url#lightbox">lightbox and zoom</a></b> are free features now</p>
|
55 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #b20ab8; color: black;
|
56 |
-
background-color: #eee; border-radius: 25px 5px;">New:
|
57 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid navy; color: black;
|
58 |
background-color: #eee; border-radius: 25px 5px;">New: supports Tumblr videos now</p>
|
|
|
|
|
59 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid chartreuse; color: black;
|
60 |
background-color: #eee; border-radius: 25px 5px;">What should be the next plugin feature? Vote <a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">here</a>.</p>
|
61 |
<!--p style="font-size: 12px; padding: 5px; border-left: 6px solid #3627c2; color: black;
|
62 |
background-color: #eee; border-radius: 25px 5px;">New: apply a <b><a href="admin.php?page=featured-image-from-url#css">CSS Style</a></b> to all your external featured images. It's a free feature now (16% of <a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">votes</a>)</p-->
|
63 |
<center>
|
64 |
-
<table
|
65 |
<tbody>
|
66 |
<tr>
|
67 |
<th>premium live preview:</th>
|
50 |
<div style="<?php echo $show_news ?>">
|
51 |
<br>
|
52 |
<hr>
|
|
|
|
|
53 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid #b20ab8; color: black;
|
54 |
+
background-color: #eee; border-radius: 25px 5px;">New: WooCommerce <a href="admin.php?page=featured-image-from-url#variable">Product Variable</a> support (<a href="https://shop.featuredimagefromurl.com/product/variable-product/">live preview</a>)</p>
|
55 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid navy; color: black;
|
56 |
background-color: #eee; border-radius: 25px 5px;">New: supports Tumblr videos now</p>
|
57 |
+
<p style="font-size: 12px; padding: 5px; border-left: 6px solid orange; color: black;
|
58 |
+
background-color: #eee; border-radius: 25px 5px;">New: if the Alt/Title field is empty then automatically set that with the post/page/product title</p>
|
59 |
<p style="font-size: 12px; padding: 5px; border-left: 6px solid chartreuse; color: black;
|
60 |
background-color: #eee; border-radius: 25px 5px;">What should be the next plugin feature? Vote <a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">here</a>.</p>
|
61 |
<!--p style="font-size: 12px; padding: 5px; border-left: 6px solid #3627c2; color: black;
|
62 |
background-color: #eee; border-radius: 25px 5px;">New: apply a <b><a href="admin.php?page=featured-image-from-url#css">CSS Style</a></b> to all your external featured images. It's a free feature now (16% of <a href="https://goo.gl/forms/TxLdhwXTqsuO5BHg2">votes</a>)</p-->
|
63 |
<center>
|
64 |
+
<table>
|
65 |
<tbody>
|
66 |
<tr>
|
67 |
<th>premium live preview:</th>
|
admin/menu.php
CHANGED
@@ -37,12 +37,10 @@ function fifu_get_menu_html() {
|
|
37 |
|
38 |
fifu_update_menu_options();
|
39 |
|
40 |
-
if (
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
fifu_disable_fake();
|
45 |
-
}
|
46 |
}
|
47 |
|
48 |
function fifu_get_menu_settings() {
|
@@ -114,8 +112,32 @@ function fifu_update_option($input, $type) {
|
|
114 |
}
|
115 |
|
116 |
function fifu_enable_fake() {
|
|
|
|
|
|
|
117 |
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
|
|
119 |
$table = $wpdb->prefix . 'postmeta';
|
120 |
$query = "
|
121 |
SELECT DISTINCT post_id
|
@@ -135,83 +157,37 @@ function fifu_enable_fake() {
|
|
135 |
)";
|
136 |
$result = $wpdb->get_results($query);
|
137 |
foreach ($result as $i) {
|
138 |
-
// create attachment
|
139 |
-
$filename = 'Featured Image from URL';
|
140 |
-
$parent_post_id = null;
|
141 |
-
$filetype = wp_check_filetype('fifu.png', null);
|
142 |
-
$attachment = array(
|
143 |
-
'guid' => fifu_main_image_url($i->post_id),
|
144 |
-
'post_mime_type' => $filetype['type'],
|
145 |
-
'post_author' => 0,
|
146 |
-
'post_title' => '',
|
147 |
-
'post_excerpt' => '',
|
148 |
-
'post_content' => 'Please don\'t remove that. It\'s just an empty symbolic file that keeps the field filled ' .
|
149 |
-
'(some themes/plugins depend on having an attached file to work). But you are free to use any image you want instead of this file.',
|
150 |
-
'post_status' => 'inherit'
|
151 |
-
);
|
152 |
-
$attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
|
153 |
-
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
154 |
-
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
|
155 |
-
wp_update_attachment_metadata($attach_id, $attach_data);
|
156 |
-
|
157 |
-
// create _thumbnail_id
|
158 |
$data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
|
159 |
$wpdb->insert($table, $data);
|
160 |
}
|
161 |
-
}
|
162 |
|
163 |
-
|
164 |
-
|
|
|
|
|
165 |
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
171 |
$result = $wpdb->get_results($query);
|
172 |
foreach ($result as $i) {
|
173 |
-
$
|
174 |
-
$
|
175 |
-
|
176 |
}
|
|
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
$
|
181 |
-
|
182 |
-
|
183 |
-
$wpdb->delete($table, $where);
|
184 |
-
|
185 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $i->post_id, 'meta_value' => null);
|
186 |
-
$wpdb->delete($table, $where);
|
187 |
-
|
188 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $i->post_id, 'meta_value' => 'fifu:' . $i->post_id);
|
189 |
-
$wpdb->delete($table, $where);
|
190 |
-
|
191 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $i->post_id, 'meta_value' => get_option('fifu_fake_attach_id'));
|
192 |
-
$wpdb->delete($table, $where);
|
193 |
-
|
194 |
-
$where = array('meta_key' => '_wp_attached_file', 'post_id' => $i->post_id, 'meta_value' => 'Featured Image from URL');
|
195 |
-
$wpdb->delete($table, $where);
|
196 |
-
|
197 |
-
// delete _thumbnail_id withouth attachment
|
198 |
-
$query = "SELECT 1 FROM " . $table . " pm WHERE pm.meta_key = '_thumbnail_id' AND pm.post_id = " . $i->post_id . " AND NOT EXISTS (SELECT 1 FROM " . $table_posts . " p WHERE p.id = pm.meta_value)";
|
199 |
-
$result = $wpdb->get_results($query);
|
200 |
-
foreach ($result as $x) {
|
201 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $i->post_id);
|
202 |
-
$wpdb->delete($table, $where);
|
203 |
-
}
|
204 |
-
}
|
205 |
|
|
|
206 |
delete_option('fifu_fake_attach_id');
|
207 |
-
|
208 |
-
// delete attachments
|
209 |
-
$query = "SELECT post_id FROM " . $table . " WHERE meta_key = '_wp_attached_file' AND meta_value = 'Featured Image from URL'";
|
210 |
-
$result = $wpdb->get_results($query);
|
211 |
-
foreach ($result as $i) {
|
212 |
-
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $i->post_id);
|
213 |
-
$wpdb->delete($table, $where);
|
214 |
-
wp_delete_attachment($i->post_id);
|
215 |
-
}
|
216 |
}
|
217 |
|
37 |
|
38 |
fifu_update_menu_options();
|
39 |
|
40 |
+
if (get_option('fifu_fake') == 'toggleon')
|
41 |
+
fifu_enable_fake();
|
42 |
+
else
|
43 |
+
fifu_disable_fake();
|
|
|
|
|
44 |
}
|
45 |
|
46 |
function fifu_get_menu_settings() {
|
112 |
}
|
113 |
|
114 |
function fifu_enable_fake() {
|
115 |
+
if (get_option('fifu_fake_attach_id'))
|
116 |
+
return;
|
117 |
+
|
118 |
global $wpdb;
|
119 |
+
$old_attach_id = get_option('fifu_fake_attach_id');
|
120 |
+
|
121 |
+
// create attachment
|
122 |
+
$filename = 'Featured Image from URL';
|
123 |
+
$parent_post_id = null;
|
124 |
+
$filetype = wp_check_filetype('fifu.png', null);
|
125 |
+
$attachment = array(
|
126 |
+
'guid' => basename($filename),
|
127 |
+
'post_mime_type' => $filetype['type'],
|
128 |
+
'post_title' => '',
|
129 |
+
'post_excerpt' => '',
|
130 |
+
'post_content' => 'Please don\'t remove that. It\'s just an empty symbolic file that keeps the field filled ' .
|
131 |
+
'(some themes/plugins depend on having an attached file to work). But you are free to use any image you want instead of this file.',
|
132 |
+
'post_status' => 'inherit'
|
133 |
+
);
|
134 |
+
$attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
|
135 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
136 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
|
137 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
138 |
+
update_option('fifu_fake_attach_id', $attach_id);
|
139 |
|
140 |
+
// insert _thumbnail_id
|
141 |
$table = $wpdb->prefix . 'postmeta';
|
142 |
$query = "
|
143 |
SELECT DISTINCT post_id
|
157 |
)";
|
158 |
$result = $wpdb->get_results($query);
|
159 |
foreach ($result as $i) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
$data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
|
161 |
$wpdb->insert($table, $data);
|
162 |
}
|
|
|
163 |
|
164 |
+
// update _thumbnail_id
|
165 |
+
$data = array('meta_value' => $attach_id);
|
166 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $old_attach_id);
|
167 |
+
$wpdb->update($table, $data, $where, null, null);
|
168 |
|
169 |
+
// update _thumbnail_id
|
170 |
+
$query = "
|
171 |
+
SELECT post_id
|
172 |
+
FROM " . $table . " a
|
173 |
+
WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
174 |
+
AND a.meta_value IS NOT NULL
|
175 |
+
AND a.meta_value <> ''";
|
176 |
$result = $wpdb->get_results($query);
|
177 |
foreach ($result as $i) {
|
178 |
+
$data = array('meta_value' => $attach_id);
|
179 |
+
$where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1);
|
180 |
+
$wpdb->update($table, $data, $where, null, null);
|
181 |
}
|
182 |
+
}
|
183 |
|
184 |
+
function fifu_disable_fake() {
|
185 |
+
global $wpdb;
|
186 |
+
$table = $wpdb->prefix . 'postmeta';
|
187 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_fake_attach_id'));
|
188 |
+
$wpdb->delete($table, $where);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
+
wp_delete_attachment(get_option('fifu_fake_attach_id'));
|
191 |
delete_option('fifu_fake_attach_id');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
|
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.
|
8 |
* Author: Marcel Jacques Machado
|
9 |
* Author URI: https://www.linkedin.com/in/marceljm/
|
10 |
*/
|
@@ -25,36 +25,3 @@ if (is_admin()) {
|
|
25 |
require_once( FIFU_ADMIN_DIR . '/column.php' );
|
26 |
require_once( FIFU_ADMIN_DIR . '/category.php' );
|
27 |
}
|
28 |
-
|
29 |
-
/* deactivate */
|
30 |
-
|
31 |
-
register_deactivation_hook(__FILE__, 'fifu_deactivate');
|
32 |
-
|
33 |
-
function fifu_deactivate($network_wide) {
|
34 |
-
error_log('FIFU deactivated');
|
35 |
-
fifu_init(false, $network_wide);
|
36 |
-
}
|
37 |
-
|
38 |
-
/* activate */
|
39 |
-
|
40 |
-
register_activation_hook(__FILE__, 'fifu_activate');
|
41 |
-
|
42 |
-
function fifu_activate($network_wide) {
|
43 |
-
error_log('FIFU activated');
|
44 |
-
fifu_init(true, $network_wide);
|
45 |
-
}
|
46 |
-
|
47 |
-
/* init function */
|
48 |
-
|
49 |
-
function fifu_init($enabled, $network_wide) {
|
50 |
-
require_once( FIFU_ADMIN_DIR . '/menu.php' );
|
51 |
-
if (is_multisite() && $network_wide) {
|
52 |
-
global $wpdb;
|
53 |
-
foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
|
54 |
-
switch_to_blog($blog_id);
|
55 |
-
$enabled ? fifu_enable_fake() : fifu_disable_fake();
|
56 |
-
}
|
57 |
-
} else
|
58 |
-
$enabled ? fifu_enable_fake() : fifu_disable_fake();
|
59 |
-
}
|
60 |
-
|
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.5
|
8 |
* Author: Marcel Jacques Machado
|
9 |
* Author URI: https://www.linkedin.com/in/marceljm/
|
10 |
*/
|
25 |
require_once( FIFU_ADMIN_DIR . '/column.php' );
|
26 |
require_once( FIFU_ADMIN_DIR . '/category.php' );
|
27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/external-post.php
CHANGED
@@ -88,68 +88,7 @@ function fifu_first_url_in_content($post_id) {
|
|
88 |
}
|
89 |
|
90 |
function fifu_update_fake_attach_id($post_id) {
|
91 |
-
|
92 |
-
|
93 |
-
$table_posts = $wpdb->prefix . 'posts';
|
94 |
-
|
95 |
-
// delete attachment created by fifu
|
96 |
-
$query = "SELECT 1 FROM " . $table_posts . " WHERE post_type = 'attachment' AND post_content LIKE 'Please don%' AND id = " . $post_id;
|
97 |
-
$result = $wpdb->get_results($query);
|
98 |
-
foreach ($result as $i) {
|
99 |
-
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $post_id);
|
100 |
-
$wpdb->delete($table, $where);
|
101 |
-
wp_delete_attachment($post_id);
|
102 |
-
}
|
103 |
-
|
104 |
-
// delete _thumbnail_id withouth attachment
|
105 |
-
$query = "SELECT 1 FROM " . $table . " pm WHERE pm.meta_key = '_thumbnail_id' AND pm.post_id = " . $post_id . " AND NOT EXISTS (SELECT 1 FROM " . $table_posts . " p WHERE p.id = pm.meta_value)";
|
106 |
-
$result = $wpdb->get_results($query);
|
107 |
-
foreach ($result as $i) {
|
108 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $post_id);
|
109 |
-
$wpdb->delete($table, $where);
|
110 |
-
}
|
111 |
-
|
112 |
-
// delete meta values
|
113 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $post_id, 'meta_value' => -1);
|
114 |
-
$wpdb->delete($table, $where);
|
115 |
-
|
116 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $post_id, 'meta_value' => null);
|
117 |
-
$wpdb->delete($table, $where);
|
118 |
-
|
119 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $post_id, 'meta_value' => 'fifu:' . $post_id);
|
120 |
-
$wpdb->delete($table, $where);
|
121 |
-
|
122 |
-
$where = array('meta_key' => '_thumbnail_id', 'post_id' => $post_id, 'meta_value' => get_option('fifu_fake_attach_id'));
|
123 |
-
$wpdb->delete($table, $where);
|
124 |
-
|
125 |
-
$where = array('meta_key' => '_wp_attached_file', 'post_id' => $post_id, 'meta_value' => 'Featured Image from URL');
|
126 |
-
$wpdb->delete($table, $where);
|
127 |
-
|
128 |
-
// check if has attachment (real)
|
129 |
-
if (get_post_meta($post_id, '_thumbnail_id', true))
|
130 |
-
return;
|
131 |
-
|
132 |
-
// create attachment (fake)
|
133 |
-
$filename = 'Featured Image from URL';
|
134 |
-
$parent_post_id = null;
|
135 |
-
$filetype = wp_check_filetype('fifu.png', null);
|
136 |
-
$attachment = array(
|
137 |
-
'guid' => fifu_main_image_url($post_id),
|
138 |
-
'post_mime_type' => $filetype['type'],
|
139 |
-
'post_author' => 0,
|
140 |
-
'post_title' => '',
|
141 |
-
'post_excerpt' => '',
|
142 |
-
'post_content' => 'Please don\'t remove that. It\'s just an empty symbolic file that keeps the field filled ' .
|
143 |
-
'(some themes/plugins depend on having an attached file to work). But you are free to use any image you want instead of this file.',
|
144 |
-
'post_status' => 'inherit'
|
145 |
-
);
|
146 |
-
$attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
|
147 |
-
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
148 |
-
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
|
149 |
-
wp_update_attachment_metadata($attach_id, $attach_data);
|
150 |
-
|
151 |
-
// add _thumbnail_id
|
152 |
-
$data = array('post_id' => $post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
|
153 |
-
$wpdb->insert($table, $data);
|
154 |
}
|
155 |
|
88 |
}
|
89 |
|
90 |
function fifu_update_fake_attach_id($post_id) {
|
91 |
+
if (get_option('fifu_fake_attach_id') && !get_post_thumbnail_id($post_id))
|
92 |
+
set_post_thumbnail($post_id, get_option('fifu_fake_attach_id'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
includes/html/js/image.js
CHANGED
@@ -4,7 +4,6 @@ jQuery(document).ready(function ($) {
|
|
4 |
jQuery('div.flex-viewport').each(function (index) {
|
5 |
jQuery(this).css('height', '');
|
6 |
});
|
7 |
-
resizeImg($);
|
8 |
}, 500);
|
9 |
});
|
10 |
|
@@ -18,15 +17,3 @@ function disableClick($) {
|
|
18 |
});
|
19 |
}
|
20 |
}
|
21 |
-
|
22 |
-
function resizeImg($) {
|
23 |
-
jQuery("div.woocommerce-product-gallery").find('img').each(function (index) {
|
24 |
-
//original size
|
25 |
-
var width = $(this).context.clientWidth;
|
26 |
-
var height = $(this).context.clientHeight;
|
27 |
-
var ratio = width / height;
|
28 |
-
jQuery(this).attr('data-large_image_width', jQuery(window).width() * ratio);
|
29 |
-
jQuery(this).attr('data-large_image_height', jQuery(window).width());
|
30 |
-
});
|
31 |
-
}
|
32 |
-
|
4 |
jQuery('div.flex-viewport').each(function (index) {
|
5 |
jQuery(this).css('height', '');
|
6 |
});
|
|
|
7 |
}, 500);
|
8 |
});
|
9 |
|
17 |
});
|
18 |
}
|
19 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/thumbnail.php
CHANGED
@@ -40,20 +40,21 @@ function fifu_choose($post) {
|
|
40 |
|
41 |
$image_url = fifu_main_image_url($post_id);
|
42 |
|
43 |
-
$
|
44 |
|
45 |
if ($image_url || get_option('fifu_default_url')) {
|
46 |
-
if (!$
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
|
52 |
|
53 |
function fifu_replace($html, $post_id) {
|
54 |
-
if (is_singular('product'))
|
55 |
-
return $html;
|
56 |
-
|
57 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
58 |
$alt = get_post_meta($post_id, 'fifu_image_alt', true);
|
59 |
|
@@ -90,43 +91,33 @@ function fifu_add_to_content($content) {
|
|
90 |
add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
|
91 |
|
92 |
function fifu_replace_attachment_url($att_url, $att_id) {
|
93 |
-
|
94 |
-
|
95 |
-
if (!$post || fifu_show_internal_instead_of_external($post->id))
|
96 |
return $att_url;
|
97 |
|
98 |
-
$
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
102 |
return $att_url;
|
103 |
}
|
104 |
|
105 |
-
add_filter('
|
106 |
-
|
107 |
-
function fifu_query_attachments($where) {
|
108 |
-
if (isset($_POST['action']) && ($_POST['action'] == 'query-attachments'))
|
109 |
-
$where .= ' AND post_author <> 0 ';
|
110 |
-
return $where;
|
111 |
-
}
|
112 |
-
|
113 |
-
add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
|
114 |
-
|
115 |
-
function fifu_replace_attachment_image_src($image, $att_id, $size) {
|
116 |
-
$post = get_post($att_id);
|
117 |
|
118 |
-
|
|
|
119 |
return $image;
|
120 |
|
121 |
-
$
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
130 |
}
|
131 |
return $image;
|
132 |
}
|
@@ -144,21 +135,29 @@ function fifu_genesis_image($args, $var1, $var2, $src) {
|
|
144 |
function fifu_main_image_url($post_id) {
|
145 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
146 |
|
147 |
-
if (!$url &&
|
148 |
$url = get_option('fifu_default_url');
|
149 |
|
150 |
return $url;
|
151 |
}
|
152 |
|
|
|
|
|
|
|
|
|
153 |
function fifu_lazy_url($url) {
|
154 |
if (get_option('fifu_lazy') != 'toggleon' || is_ajax_call())
|
155 |
return 'src="' . $url . '"';
|
156 |
return (is_home() || (class_exists('WooCommerce') && is_shop()) ? 'data-src="' : 'src="') . $url . '"';
|
157 |
}
|
158 |
|
|
|
|
|
|
|
|
|
159 |
function fifu_has_internal_image($post_id) {
|
160 |
-
$
|
161 |
-
return $
|
162 |
}
|
163 |
|
164 |
function fifu_show_internal_instead_of_external($post_id) {
|
@@ -174,34 +173,3 @@ function fifu_is_in_editor() {
|
|
174 |
function fifu_internal_priority() {
|
175 |
return get_option('fifu_priority') == 'toggleon';
|
176 |
}
|
177 |
-
|
178 |
-
function fifu_get_image_sizes() {
|
179 |
-
global $_wp_additional_image_sizes;
|
180 |
-
$sizes = array();
|
181 |
-
foreach (get_intermediate_image_sizes() as $_size) {
|
182 |
-
if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
|
183 |
-
$sizes[$_size]['width'] = get_option("{$_size}_size_w");
|
184 |
-
$sizes[$_size]['height'] = get_option("{$_size}_size_h");
|
185 |
-
$sizes[$_size]['crop'] = (bool) get_option("{$_size}_crop");
|
186 |
-
} elseif (isset($_wp_additional_image_sizes[$_size])) {
|
187 |
-
$sizes[$_size] = array(
|
188 |
-
'width' => $_wp_additional_image_sizes[$_size]['width'],
|
189 |
-
'height' => $_wp_additional_image_sizes[$_size]['height'],
|
190 |
-
'crop' => $_wp_additional_image_sizes[$_size]['crop'],
|
191 |
-
);
|
192 |
-
}
|
193 |
-
}
|
194 |
-
return $sizes;
|
195 |
-
}
|
196 |
-
|
197 |
-
function fifu_get_image_size($size) {
|
198 |
-
$sizes = fifu_get_image_sizes();
|
199 |
-
if (is_array($size)) {
|
200 |
-
$arr_size = array();
|
201 |
-
$arr_size['width'] = $size[0];
|
202 |
-
$arr_size['height'] = $size[1];
|
203 |
-
return $arr_size;
|
204 |
-
}
|
205 |
-
return isset($sizes[$size]) ? $sizes[$size] : false;
|
206 |
-
}
|
207 |
-
|
40 |
|
41 |
$image_url = fifu_main_image_url($post_id);
|
42 |
|
43 |
+
$featured_image = get_post_meta($post_id, '_thumbnail_id', true);
|
44 |
|
45 |
if ($image_url || get_option('fifu_default_url')) {
|
46 |
+
if (!$featured_image)
|
47 |
+
update_post_meta($post_id, '_thumbnail_id', -1);
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
if ($featured_image == -1)
|
51 |
+
delete_post_meta($post_id, '_thumbnail_id');
|
52 |
}
|
53 |
}
|
54 |
|
55 |
add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
|
56 |
|
57 |
function fifu_replace($html, $post_id) {
|
|
|
|
|
|
|
58 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
59 |
$alt = get_post_meta($post_id, 'fifu_image_alt', true);
|
60 |
|
91 |
add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
|
92 |
|
93 |
function fifu_replace_attachment_url($att_url, $att_id) {
|
94 |
+
if (fifu_show_internal_instead_of_external(get_the_ID()))
|
|
|
|
|
95 |
return $att_url;
|
96 |
|
97 |
+
if ($att_id == get_post_thumbnail_id(get_the_ID())) {
|
98 |
+
$url = fifu_main_image_url(get_the_ID());
|
99 |
+
if ($url)
|
100 |
+
$att_url = $url;
|
101 |
+
}
|
102 |
return $att_url;
|
103 |
}
|
104 |
|
105 |
+
add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
+
function fifu_replace_attachment_image_src($image, $att_id) {
|
108 |
+
if (fifu_show_internal_instead_of_external(get_the_ID()))
|
109 |
return $image;
|
110 |
|
111 |
+
if ($att_id == get_post_thumbnail_id(get_the_ID())) {
|
112 |
+
$url = fifu_main_image_url(get_the_ID());
|
113 |
+
if ($url) {
|
114 |
+
return array(
|
115 |
+
$url,
|
116 |
+
0,
|
117 |
+
0,
|
118 |
+
false
|
119 |
+
);
|
120 |
+
}
|
121 |
}
|
122 |
return $image;
|
123 |
}
|
135 |
function fifu_main_image_url($post_id) {
|
136 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
137 |
|
138 |
+
if (!$url && fifu_no_internal_image($post_id))
|
139 |
$url = get_option('fifu_default_url');
|
140 |
|
141 |
return $url;
|
142 |
}
|
143 |
|
144 |
+
function fifu_no_internal_image($post_id) {
|
145 |
+
return get_post_meta($post_id, '_thumbnail_id', true) == -1;
|
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) {
|
159 |
+
$featured_image = get_post_meta($post_id, '_thumbnail_id', true);
|
160 |
+
return $featured_image && $featured_image != -1 && $featured_image != get_option('fifu_fake_attach_id');
|
161 |
}
|
162 |
|
163 |
function fifu_show_internal_instead_of_external($post_id) {
|
173 |
function fifu_internal_priority() {
|
174 |
return get_option('fifu_priority') == 'toggleon';
|
175 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -159,6 +159,9 @@ Features:
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
162 |
= 1.9.4 =
|
163 |
* New: Bug fix.
|
164 |
|
@@ -399,6 +402,9 @@ was removed. To finish, a Premium version is now been presented.
|
|
399 |
|
400 |
== Upgrade Notice ==
|
401 |
|
|
|
|
|
|
|
402 |
= 1.9.4 =
|
403 |
* New: Bug fix.
|
404 |
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 1.9.5 =
|
163 |
+
* Back to the version 1.9.1.
|
164 |
+
|
165 |
= 1.9.4 =
|
166 |
* New: Bug fix.
|
167 |
|
402 |
|
403 |
== Upgrade Notice ==
|
404 |
|
405 |
+
= 1.9.5 =
|
406 |
+
* Back to the version 1.9.1.
|
407 |
+
|
408 |
= 1.9.4 =
|
409 |
* New: Bug fix.
|
410 |
|