Version Description
- New: Bug fix.
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 1.9.3 |
Comparing to | |
See all releases |
Code changes from version 1.9.2 to 1.9.3
- admin/html/menu.html +27 -0
- admin/menu.php +128 -0
- featured-image-from-url.php +19 -15
- includes/external-post.php +16 -8
- includes/thumbnail.php +29 -1
- readme.txt +6 -0
admin/html/menu.html
CHANGED
@@ -183,6 +183,33 @@
|
|
183 |
</form>
|
184 |
</div>
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
<div class="box">
|
187 |
<h2>Featured Image Column</h2>
|
188 |
<div class="greybox" id="grad1">
|
183 |
</form>
|
184 |
</div>
|
185 |
|
186 |
+
<div class="box">
|
187 |
+
<h2>Fake Internal Featured Image</h2>
|
188 |
+
<div class="greybox" id="grad1">
|
189 |
+
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.
|
190 |
+
</div>
|
191 |
+
<p/>
|
192 |
+
<form
|
193 |
+
id="fifu_form_fake"
|
194 |
+
action="javascript:void(0)"
|
195 |
+
method="post">
|
196 |
+
<input
|
197 |
+
type="image"
|
198 |
+
href="javascript:void(0)"
|
199 |
+
id="fifu_toggle_fake"
|
200 |
+
onclick="invert('fake')"
|
201 |
+
name="fifu_toggle_fake"
|
202 |
+
class="<?php echo $enable_fake; ?>"
|
203 |
+
value=""
|
204 |
+
style="display:block" >
|
205 |
+
<input
|
206 |
+
type="hidden"
|
207 |
+
id="fifu_input_fake"
|
208 |
+
name="fifu_input_fake"
|
209 |
+
value="" >
|
210 |
+
</form>
|
211 |
+
</div>
|
212 |
+
|
213 |
<div class="box">
|
214 |
<h2>Featured Image Column</h2>
|
215 |
<div class="greybox" id="grad1">
|
admin/menu.php
CHANGED
@@ -16,6 +16,7 @@ function fifu_get_menu_html() {
|
|
16 |
$enable_social = get_option('fifu_social');
|
17 |
$enable_lazy = get_option('fifu_lazy');
|
18 |
$enable_content = get_option('fifu_content');
|
|
|
19 |
$css_style = get_option('fifu_css');
|
20 |
$default_url = get_option('fifu_default_url');
|
21 |
$enable_wc_lbox = get_option('fifu_wc_lbox');
|
@@ -35,12 +36,18 @@ function fifu_get_menu_html() {
|
|
35 |
include 'html/menu.html';
|
36 |
|
37 |
fifu_update_menu_options();
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
function fifu_get_menu_settings() {
|
41 |
fifu_get_setting('fifu_social');
|
42 |
fifu_get_setting('fifu_lazy');
|
43 |
fifu_get_setting('fifu_content');
|
|
|
44 |
fifu_get_setting('fifu_css');
|
45 |
fifu_get_setting('fifu_default_url');
|
46 |
fifu_get_setting('fifu_wc_lbox');
|
@@ -76,6 +83,7 @@ function fifu_update_menu_options() {
|
|
76 |
fifu_update_option('fifu_input_social', 'fifu_social');
|
77 |
fifu_update_option('fifu_input_lazy', 'fifu_lazy');
|
78 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
|
|
79 |
fifu_update_option('fifu_input_css', 'fifu_css');
|
80 |
fifu_update_option('fifu_input_default_url', 'fifu_default_url');
|
81 |
fifu_update_option('fifu_input_wc_lbox', 'fifu_wc_lbox');
|
@@ -103,3 +111,123 @@ function fifu_update_option($input, $type) {
|
|
103 |
}
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
$enable_social = get_option('fifu_social');
|
17 |
$enable_lazy = get_option('fifu_lazy');
|
18 |
$enable_content = get_option('fifu_content');
|
19 |
+
$enable_fake = get_option('fifu_fake');
|
20 |
$css_style = get_option('fifu_css');
|
21 |
$default_url = get_option('fifu_default_url');
|
22 |
$enable_wc_lbox = get_option('fifu_wc_lbox');
|
36 |
include 'html/menu.html';
|
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() {
|
47 |
fifu_get_setting('fifu_social');
|
48 |
fifu_get_setting('fifu_lazy');
|
49 |
fifu_get_setting('fifu_content');
|
50 |
+
fifu_get_setting('fifu_fake');
|
51 |
fifu_get_setting('fifu_css');
|
52 |
fifu_get_setting('fifu_default_url');
|
53 |
fifu_get_setting('fifu_wc_lbox');
|
83 |
fifu_update_option('fifu_input_social', 'fifu_social');
|
84 |
fifu_update_option('fifu_input_lazy', 'fifu_lazy');
|
85 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
86 |
+
fifu_update_option('fifu_input_fake', 'fifu_fake');
|
87 |
fifu_update_option('fifu_input_css', 'fifu_css');
|
88 |
fifu_update_option('fifu_input_default_url', 'fifu_default_url');
|
89 |
fifu_update_option('fifu_input_wc_lbox', 'fifu_wc_lbox');
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
function fifu_enable_fake() {
|
115 |
+
global $wpdb;
|
116 |
+
|
117 |
+
// create attachment
|
118 |
+
$filename = 'Featured Image from URL';
|
119 |
+
$parent_post_id = null;
|
120 |
+
$filetype = wp_check_filetype('fifu.png', null);
|
121 |
+
$attachment = array(
|
122 |
+
'guid' => basename($filename),
|
123 |
+
'post_mime_type' => $filetype['type'],
|
124 |
+
'post_title' => '',
|
125 |
+
'post_excerpt' => '',
|
126 |
+
'post_content' => 'Please don\'t remove that. It\'s just an empty symbolic file that keeps the field filled ' .
|
127 |
+
'(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.',
|
128 |
+
'post_status' => 'inherit'
|
129 |
+
);
|
130 |
+
$attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
|
131 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
132 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
|
133 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
134 |
+
update_option('fifu_fake_attach_id', $attach_id);
|
135 |
+
|
136 |
+
$table = $wpdb->prefix . 'postmeta';
|
137 |
+
|
138 |
+
// delete _thumbnail_id (new)
|
139 |
+
$query = "DELETE FROM " . $table . " WHERE meta_key = '_thumbnail_id' AND meta_value LIKE 'fifu:%'";
|
140 |
+
$wpdb->query($query);
|
141 |
+
|
142 |
+
// insert _thumbnail_id
|
143 |
+
$query = "
|
144 |
+
SELECT DISTINCT post_id
|
145 |
+
FROM " . $table . " a
|
146 |
+
WHERE a.post_id in (
|
147 |
+
SELECT post_id
|
148 |
+
FROM " . $table . " b
|
149 |
+
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
150 |
+
AND b.meta_value IS NOT NULL
|
151 |
+
AND b.meta_value <> ''
|
152 |
+
)
|
153 |
+
AND NOT EXISTS (
|
154 |
+
SELECT 1
|
155 |
+
FROM " . $table . " c
|
156 |
+
WHERE a.post_id = c.post_id
|
157 |
+
AND c.meta_key = '_thumbnail_id'
|
158 |
+
)";
|
159 |
+
$result = $wpdb->get_results($query);
|
160 |
+
foreach ($result as $i) {
|
161 |
+
$data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
|
162 |
+
$wpdb->insert($table, $data);
|
163 |
+
}
|
164 |
+
|
165 |
+
// update _thumbnail_id (fake)
|
166 |
+
$table_posts = $wpdb->prefix . 'posts';
|
167 |
+
$query = "SELECT id FROM " . $table_posts . " WHERE post_type = 'attachment' AND guid = 'http://Featured%20Image%20from%20URL'";
|
168 |
+
$result = $wpdb->get_results($query);
|
169 |
+
foreach ($result as $i) {
|
170 |
+
$data = array('meta_value' => $attach_id);
|
171 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $i->id);
|
172 |
+
$wpdb->update($table, $data, $where, null, null);
|
173 |
+
}
|
174 |
+
|
175 |
+
// update _thumbnail_id (-1)
|
176 |
+
$query = "
|
177 |
+
SELECT post_id
|
178 |
+
FROM " . $table . " a
|
179 |
+
WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
180 |
+
AND a.meta_value IS NOT NULL
|
181 |
+
AND a.meta_value <> ''";
|
182 |
+
$result = $wpdb->get_results($query);
|
183 |
+
foreach ($result as $i) {
|
184 |
+
$data = array('meta_value' => $attach_id);
|
185 |
+
$where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1);
|
186 |
+
$wpdb->update($table, $data, $where, null, null);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
function fifu_disable_fake() {
|
191 |
+
global $wpdb;
|
192 |
+
$table = $wpdb->prefix . 'postmeta';
|
193 |
+
|
194 |
+
// delete (-1)
|
195 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => -1);
|
196 |
+
$wpdb->delete($table, $where);
|
197 |
+
|
198 |
+
// delete (fake)
|
199 |
+
$table_posts = $wpdb->prefix . 'posts';
|
200 |
+
$query = "SELECT id FROM " . $table_posts . " WHERE post_type = 'attachment' AND guid = 'http://Featured%20Image%20from%20URL'";
|
201 |
+
$result = $wpdb->get_results($query);
|
202 |
+
foreach ($result as $i) {
|
203 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $i->id);
|
204 |
+
$wpdb->delete($table, $where);
|
205 |
+
wp_delete_attachment($i->id);
|
206 |
+
}
|
207 |
+
|
208 |
+
// insert _thumbnail_id (new)
|
209 |
+
$query = "
|
210 |
+
SELECT DISTINCT post_id
|
211 |
+
FROM " . $table . " a
|
212 |
+
WHERE a.post_id in (
|
213 |
+
SELECT post_id
|
214 |
+
FROM " . $table . " b
|
215 |
+
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
216 |
+
AND b.meta_value IS NOT NULL
|
217 |
+
AND b.meta_value <> ''
|
218 |
+
)
|
219 |
+
AND NOT EXISTS (
|
220 |
+
SELECT 1
|
221 |
+
FROM " . $table . " c
|
222 |
+
WHERE a.post_id = c.post_id
|
223 |
+
AND c.meta_key = '_thumbnail_id'
|
224 |
+
)";
|
225 |
+
$result = $wpdb->get_results($query);
|
226 |
+
foreach ($result as $i) {
|
227 |
+
$data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => 'fifu:' . $i->post_id);
|
228 |
+
$wpdb->insert($table, $data);
|
229 |
+
}
|
230 |
+
|
231 |
+
delete_option('fifu_fake_attach_id');
|
232 |
+
}
|
233 |
+
|
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 |
*/
|
@@ -61,6 +61,8 @@ function fifu_delete_ids() {
|
|
61 |
wp_delete_attachment($att_id);
|
62 |
delete_option('fifu_fake_attach_id');
|
63 |
}
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/* activate */
|
@@ -87,22 +89,24 @@ if (!get_option('fifu_migration')) {
|
|
87 |
function fifu_run_migration() {
|
88 |
global $wpdb;
|
89 |
|
|
|
|
|
90 |
// insert _thumbnail_id (new)
|
91 |
$table = $wpdb->prefix . 'postmeta';
|
92 |
$query = "
|
93 |
SELECT DISTINCT post_id
|
94 |
FROM " . $table . " a
|
95 |
WHERE a.post_id in (
|
96 |
-
SELECT post_id
|
97 |
-
FROM " . $table . " b
|
98 |
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
99 |
-
AND b.meta_value IS NOT NULL
|
100 |
AND b.meta_value <> ''
|
101 |
)
|
102 |
AND NOT EXISTS (
|
103 |
-
SELECT 1
|
104 |
-
FROM " . $table . " c
|
105 |
-
WHERE a.post_id = c.post_id
|
106 |
AND c.meta_key = '_thumbnail_id'
|
107 |
)";
|
108 |
$result = $wpdb->get_results($query);
|
@@ -119,16 +123,16 @@ function fifu_run_migration() {
|
|
119 |
SELECT DISTINCT post_id
|
120 |
FROM " . $table . " a
|
121 |
WHERE a.post_id in (
|
122 |
-
SELECT post_id
|
123 |
-
FROM " . $table . " b
|
124 |
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
125 |
-
AND b.meta_value IS NOT NULL
|
126 |
AND b.meta_value <> ''
|
127 |
)
|
128 |
AND EXISTS (
|
129 |
-
SELECT 1
|
130 |
-
FROM " . $table . " c
|
131 |
-
WHERE a.post_id = c.post_id
|
132 |
AND c.meta_key = '_thumbnail_id'
|
133 |
AND c.meta_value = " . $att_id . "
|
134 |
)";
|
@@ -142,10 +146,10 @@ function fifu_run_migration() {
|
|
142 |
|
143 |
// update _thumbnail_id (-1)
|
144 |
$query = "
|
145 |
-
SELECT post_id
|
146 |
FROM " . $table . " a
|
147 |
WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
148 |
-
AND a.meta_value IS NOT NULL
|
149 |
AND a.meta_value <> ''";
|
150 |
$result = $wpdb->get_results($query);
|
151 |
foreach ($result as $i) {
|
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.3
|
8 |
* Author: Marcel Jacques Machado
|
9 |
* Author URI: https://www.linkedin.com/in/marceljm/
|
10 |
*/
|
61 |
wp_delete_attachment($att_id);
|
62 |
delete_option('fifu_fake_attach_id');
|
63 |
}
|
64 |
+
|
65 |
+
delete_option('fifu_migration');
|
66 |
}
|
67 |
|
68 |
/* activate */
|
89 |
function fifu_run_migration() {
|
90 |
global $wpdb;
|
91 |
|
92 |
+
update_option('fifu_fake', 'toggleoff');
|
93 |
+
|
94 |
// insert _thumbnail_id (new)
|
95 |
$table = $wpdb->prefix . 'postmeta';
|
96 |
$query = "
|
97 |
SELECT DISTINCT post_id
|
98 |
FROM " . $table . " a
|
99 |
WHERE a.post_id in (
|
100 |
+
SELECT post_id
|
101 |
+
FROM " . $table . " b
|
102 |
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
103 |
+
AND b.meta_value IS NOT NULL
|
104 |
AND b.meta_value <> ''
|
105 |
)
|
106 |
AND NOT EXISTS (
|
107 |
+
SELECT 1
|
108 |
+
FROM " . $table . " c
|
109 |
+
WHERE a.post_id = c.post_id
|
110 |
AND c.meta_key = '_thumbnail_id'
|
111 |
)";
|
112 |
$result = $wpdb->get_results($query);
|
123 |
SELECT DISTINCT post_id
|
124 |
FROM " . $table . " a
|
125 |
WHERE a.post_id in (
|
126 |
+
SELECT post_id
|
127 |
+
FROM " . $table . " b
|
128 |
WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
129 |
+
AND b.meta_value IS NOT NULL
|
130 |
AND b.meta_value <> ''
|
131 |
)
|
132 |
AND EXISTS (
|
133 |
+
SELECT 1
|
134 |
+
FROM " . $table . " c
|
135 |
+
WHERE a.post_id = c.post_id
|
136 |
AND c.meta_key = '_thumbnail_id'
|
137 |
AND c.meta_value = " . $att_id . "
|
138 |
)";
|
146 |
|
147 |
// update _thumbnail_id (-1)
|
148 |
$query = "
|
149 |
+
SELECT post_id
|
150 |
FROM " . $table . " a
|
151 |
WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
|
152 |
+
AND a.meta_value IS NOT NULL
|
153 |
AND a.meta_value <> ''";
|
154 |
$result = $wpdb->get_results($query);
|
155 |
foreach ($result as $i) {
|
includes/external-post.php
CHANGED
@@ -88,15 +88,23 @@ function fifu_first_url_in_content($post_id) {
|
|
88 |
}
|
89 |
|
90 |
function fifu_update_fake_attach_id($post_id) {
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
100 |
}
|
|
|
|
|
|
|
101 |
}
|
102 |
|
88 |
}
|
89 |
|
90 |
function fifu_update_fake_attach_id($post_id) {
|
91 |
+
// already has attachment
|
92 |
+
if (get_post_meta($post_id, '_thumbnail_id', true))
|
93 |
+
return;
|
94 |
+
|
95 |
+
// set fake attachment
|
96 |
+
if (get_option('fifu_fake_attach_id')) {
|
97 |
+
update_post_meta($post_id, '_thumbnail_id', get_option('fifu_fake_attach_id'));
|
98 |
+
return;
|
99 |
}
|
100 |
+
|
101 |
+
// set new format
|
102 |
+
if (fifu_main_image_url($post_id) || get_option('fifu_default_url')) {
|
103 |
+
update_post_meta($post_id, '_thumbnail_id', 'fifu:' . $post_id);
|
104 |
+
return;
|
105 |
}
|
106 |
+
|
107 |
+
// delete
|
108 |
+
delete_post_meta($post_id, '_thumbnail_id');
|
109 |
}
|
110 |
|
includes/thumbnail.php
CHANGED
@@ -75,6 +75,16 @@ function fifu_add_to_content($content) {
|
|
75 |
add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
|
76 |
|
77 |
function fifu_replace_attachment_url($att_url, $att_id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
$post_id = strpos($att_id, 'fifu') !== false ? explode(':', $att_id)[1] : null;
|
79 |
|
80 |
if (!$post_id)
|
@@ -91,6 +101,24 @@ function fifu_replace_attachment_url($att_url, $att_id) {
|
|
91 |
add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
|
92 |
|
93 |
function fifu_replace_attachment_image_src($image, $att_id, $size) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
$post_id = strpos($att_id, 'fifu') !== false ? explode(':', $att_id)[1] : null;
|
95 |
|
96 |
if (!$post_id)
|
@@ -139,7 +167,7 @@ function fifu_lazy_url($url) {
|
|
139 |
|
140 |
function fifu_has_internal_image($post_id) {
|
141 |
$att_id = get_post_meta($post_id, '_thumbnail_id', true);
|
142 |
-
return $att_id && strpos($att_id, "fifu") === false;
|
143 |
}
|
144 |
|
145 |
function fifu_show_internal_instead_of_external($post_id) {
|
75 |
add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
|
76 |
|
77 |
function fifu_replace_attachment_url($att_url, $att_id) {
|
78 |
+
if (get_option('fifu_fake_attach_id')) {
|
79 |
+
if (fifu_show_internal_instead_of_external(get_the_ID()))
|
80 |
+
return $att_url;
|
81 |
+
|
82 |
+
if ($att_id == get_post_thumbnail_id(get_the_ID()))
|
83 |
+
$url = fifu_main_image_url(get_the_ID());
|
84 |
+
|
85 |
+
return $url ? $url : $att_url;
|
86 |
+
}
|
87 |
+
|
88 |
$post_id = strpos($att_id, 'fifu') !== false ? explode(':', $att_id)[1] : null;
|
89 |
|
90 |
if (!$post_id)
|
101 |
add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3);
|
102 |
|
103 |
function fifu_replace_attachment_image_src($image, $att_id, $size) {
|
104 |
+
if (get_option('fifu_fake_attach_id')) {
|
105 |
+
if (fifu_show_internal_instead_of_external(get_the_ID()))
|
106 |
+
return $image;
|
107 |
+
|
108 |
+
if ($att_id == get_post_thumbnail_id(get_the_ID())) {
|
109 |
+
$url = fifu_main_image_url(get_the_ID());
|
110 |
+
if ($url) {
|
111 |
+
return array(
|
112 |
+
$url,
|
113 |
+
0,
|
114 |
+
0,
|
115 |
+
false
|
116 |
+
);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
return $image;
|
120 |
+
}
|
121 |
+
|
122 |
$post_id = strpos($att_id, 'fifu') !== false ? explode(':', $att_id)[1] : null;
|
123 |
|
124 |
if (!$post_id)
|
167 |
|
168 |
function fifu_has_internal_image($post_id) {
|
169 |
$att_id = get_post_meta($post_id, '_thumbnail_id', true);
|
170 |
+
return $att_id && strpos($att_id, "fifu") === false && $att_id != -1 && $att_id != get_option('fifu_fake_attach_id');
|
171 |
}
|
172 |
|
173 |
function fifu_show_internal_instead_of_external($post_id) {
|
readme.txt
CHANGED
@@ -159,6 +159,9 @@ Features:
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
162 |
= 1.9.2 =
|
163 |
* New: WooCommerce lightbox and zoom.
|
164 |
|
@@ -393,6 +396,9 @@ was removed. To finish, a Premium version is now been presented.
|
|
393 |
|
394 |
== Upgrade Notice ==
|
395 |
|
|
|
|
|
|
|
396 |
= 1.9.2 =
|
397 |
* New: WooCommerce lightbox and zoom.
|
398 |
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 1.9.3 =
|
163 |
+
* New: Bug fix.
|
164 |
+
|
165 |
= 1.9.2 =
|
166 |
* New: WooCommerce lightbox and zoom.
|
167 |
|
396 |
|
397 |
== Upgrade Notice ==
|
398 |
|
399 |
+
= 1.9.3 =
|
400 |
+
* New: Bug fix.
|
401 |
+
|
402 |
= 1.9.2 =
|
403 |
* New: WooCommerce lightbox and zoom.
|
404 |
|