Featured Image From URL - Version 1.9.2

Version Description

  • New: WooCommerce lightbox and zoom.
Download this release

Release Info

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

Code changes from version 1.9.1 to 1.9.2

admin/html/css/menu.css CHANGED
@@ -29,6 +29,8 @@
29
  height: 24px;
30
  background: url("<?php echo $image_button ?>") 0 0 no-repeat;
31
  text-align: center !important;
 
 
32
  }
33
 
34
  .toggleoff {
@@ -51,6 +53,7 @@ th, td {
51
  border-bottom: 1px solid #ddd;
52
  padding-right: 32px;
53
  font-weight: normal;
 
54
  }
55
 
56
  th {
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
  border-bottom: 1px solid #ddd;
54
  padding-right: 32px;
55
  font-weight: normal;
56
+ font-size: 12px;
57
  }
58
 
59
  th {
admin/html/menu.html CHANGED
@@ -143,8 +143,6 @@
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,33 +183,6 @@
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
195
- id="fifu_form_fake"
196
- action="javascript:void(0)"
197
- method="post">
198
- <input
199
- type="image"
200
- href="javascript:void(0)"
201
- id="fifu_toggle_fake"
202
- onclick="invert('fake')"
203
- name="fifu_toggle_fake"
204
- class="<?php echo $enable_fake; ?>"
205
- value=""
206
- style="display:block" >
207
- <input
208
- type="hidden"
209
- id="fifu_input_fake"
210
- name="fifu_input_fake"
211
- value="" >
212
- </form>
213
- </div>
214
-
215
  <div class="box">
216
  <h2>Featured Image Column</h2>
217
  <div class="greybox" id="grad1">
@@ -409,10 +380,14 @@
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">
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
  </div>
147
  <br>
148
  <form
183
  </form>
184
  </div>
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  <div class="box">
187
  <h2>Featured Image Column</h2>
188
  <div class="greybox" id="grad1">
380
  </form>
381
  </div>
382
 
383
+ <a name="lightbox"></a>
384
+
385
  <div class="box">
386
  <h2>WooCommerce</h2>
387
  <div class="greybox" id="grad1">
388
+ You can disable the product lightbox and zoom here.
389
+ <br><br>
390
+ <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>
391
  </div>
392
  <br>
393
  <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 #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>
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: supports WooCommerce <b><a href="admin.php?page=featured-image-from-url#variable">Variable Product</a></b> (<a href="https://shop.featuredimagefromurl.com/product/variable-product/">live preview</a>)</p>
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 style="font-size: 12px;">
65
  <tbody>
66
  <tr>
67
  <th>premium live preview:</th>
admin/menu.php CHANGED
@@ -16,7 +16,6 @@ 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
- $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,18 +35,12 @@ function fifu_get_menu_html() {
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,7 +76,6 @@ function fifu_update_menu_options() {
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,83 +103,3 @@ function fifu_update_option($input, $type) {
111
  }
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
144
- FROM " . $table . " a
145
- WHERE a.post_id in (
146
- SELECT post_id
147
- FROM " . $table . " b
148
- WHERE b.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
149
- AND b.meta_value IS NOT NULL
150
- AND b.meta_value <> ''
151
- )
152
- AND NOT EXISTS (
153
- SELECT 1
154
- FROM " . $table . " c
155
- WHERE a.post_id = c.post_id
156
- AND c.meta_key = '_thumbnail_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
-
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
  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
  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
  }
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
@@ -25,3 +25,136 @@ if (is_admin()) {
25
  require_once( FIFU_ADMIN_DIR . '/column.php' );
26
  require_once( FIFU_ADMIN_DIR . '/category.php' );
27
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
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
  }
28
+
29
+ /* deactivate */
30
+
31
+ register_deactivation_hook(__FILE__, 'fifu_deactivate');
32
+
33
+ function fifu_deactivate($network_wide) {
34
+ if (is_multisite() && $network_wide) {
35
+ global $wpdb;
36
+ foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
37
+ switch_to_blog($blog_id);
38
+ fifu_delete_ids();
39
+ }
40
+ } else
41
+ fifu_delete_ids();
42
+ }
43
+
44
+ function fifu_delete_ids() {
45
+ global $wpdb;
46
+ $table = $wpdb->prefix . 'postmeta';
47
+
48
+ // new
49
+ $query = "DELETE FROM " . $table . " WHERE meta_key = '_thumbnail_id' AND meta_value LIKE 'fifu:%'";
50
+ $wpdb->query($query);
51
+
52
+ // -1
53
+ $where = array('meta_key' => '_thumbnail_id', 'meta_value' => -1);
54
+ $wpdb->delete($table, $where);
55
+
56
+ // fake
57
+ $att_id = get_option('fifu_fake_attach_id');
58
+ if ($att_id) {
59
+ $where = array('meta_key' => '_thumbnail_id', 'meta_value' => $att_id);
60
+ $wpdb->delete($table, $where);
61
+ wp_delete_attachment($att_id);
62
+ delete_option('fifu_fake_attach_id');
63
+ }
64
+ }
65
+
66
+ /* activate */
67
+
68
+ register_activation_hook(__FILE__, 'fifu_activate');
69
+
70
+ function fifu_activate($network_wide) {
71
+ if (is_multisite() && $network_wide) {
72
+ global $wpdb;
73
+ foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
74
+ switch_to_blog($blog_id);
75
+ fifu_run_migration();
76
+ }
77
+ } else
78
+ fifu_run_migration();
79
+ }
80
+
81
+ /* the code below is to migrate _thumbnail_id to a new format "fifu:post_id" */
82
+
83
+ if (!get_option('fifu_migration')) {
84
+ fifu_run_migration();
85
+ }
86
+
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);
109
+ foreach ($result as $i) {
110
+ $data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => 'fifu:' . $i->post_id);
111
+ $wpdb->insert($table, $data);
112
+ }
113
+
114
+ // update _thumbnail_id (fake)
115
+ $att_id = get_option('fifu_fake_attach_id');
116
+ if ($att_id) {
117
+ $table = $wpdb->prefix . 'postmeta';
118
+ $query = "
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
+ )";
135
+ $result = $wpdb->get_results($query);
136
+ foreach ($result as $i) {
137
+ $data = array('meta_value' => 'fifu:' . $i->post_id);
138
+ $where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $att_id);
139
+ $wpdb->update($table, $data, $where, null, null);
140
+ }
141
+ }
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) {
152
+ $data = array('meta_value' => 'fifu:' . $i->post_id);
153
+ $where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1);
154
+ $wpdb->update($table, $data, $where, null, null);
155
+ }
156
+
157
+ // migration control
158
+ update_option('fifu_migration', true);
159
+ }
160
+
includes/external-post.php CHANGED
@@ -88,7 +88,15 @@ function fifu_first_url_in_content($post_id) {
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
 
88
  }
89
 
90
  function fifu_update_fake_attach_id($post_id) {
91
+ $image_url = fifu_main_image_url($post_id);
92
+ $att_id = get_post_meta($post_id, '_thumbnail_id', true);
93
+ if ($image_url || get_option('fifu_default_url')) {
94
+ if (!$att_id)
95
+ update_post_meta($post_id, '_thumbnail_id', 'fifu:' . $post_id);
96
+ }
97
+ else {
98
+ if (strpos($att_id, "fifu") !== false)
99
+ delete_post_meta($post_id, '_thumbnail_id');
100
+ }
101
  }
102
 
includes/html/js/image.js CHANGED
@@ -4,6 +4,7 @@ jQuery(document).ready(function ($) {
4
  jQuery('div.flex-viewport').each(function (index) {
5
  jQuery(this).css('height', '');
6
  });
 
7
  }, 500);
8
  });
9
 
@@ -17,3 +18,15 @@ function disableClick($) {
17
  });
18
  }
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
4
  jQuery('div.flex-viewport').each(function (index) {
5
  jQuery(this).css('height', '');
6
  });
7
+ resizeImg($);
8
  }, 500);
9
  });
10
 
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
+
includes/thumbnail.php CHANGED
@@ -33,28 +33,12 @@ function fifu_apply_css() {
33
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {display:none !important;}</style>';
34
  }
35
 
36
- add_action('the_post', 'fifu_choose');
37
-
38
- function fifu_choose($post) {
39
- $post_id = $post->ID;
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,33 +75,39 @@ function fifu_add_to_content($content) {
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,29 +125,21 @@ function fifu_genesis_image($args, $var1, $var2, $src) {
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,3 +155,34 @@ function fifu_is_in_editor() {
173
  function fifu_internal_priority() {
174
  return get_option('fifu_priority') == 'toggleon';
175
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  echo '<style>[class$="woocommerce-product-gallery__trigger"] {display:none !important;}</style>';
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
37
 
38
  function fifu_replace($html, $post_id) {
39
+ if (is_singular('product'))
40
+ return $html;
41
+
42
  $url = get_post_meta($post_id, 'fifu_image_url', true);
43
  $alt = get_post_meta($post_id, 'fifu_image_alt', true);
44
 
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)
81
  return $att_url;
82
 
83
+ if (fifu_show_internal_instead_of_external($post_id))
84
+ return $att_url;
85
+
86
+ $url = fifu_main_image_url($post_id);
87
+
88
+ return $url ? $url : $att_url;
89
  }
90
 
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)
97
  return $image;
98
 
99
+ if (fifu_show_internal_instead_of_external($post_id))
100
+ return $image;
101
+
102
+ $url = fifu_main_image_url($post_id);
103
+ if ($url) {
104
+ $image_size = fifu_get_image_size($size);
105
+ return array(
106
+ $url,
107
+ isset($image_size['width']) ? $image_size['width'] : 800,
108
+ isset($image_size['height']) ? $image_size['height'] : 1,
109
+ isset($image_size['crop']) ? $image_size['crop'] : '',
110
+ );
111
  }
112
  return $image;
113
  }
125
  function fifu_main_image_url($post_id) {
126
  $url = get_post_meta($post_id, 'fifu_image_url', true);
127
 
128
+ if (!$url && !fifu_has_internal_image($post_id))
129
  $url = get_option('fifu_default_url');
130
 
131
  return $url;
132
  }
133
 
 
 
 
 
134
  function fifu_lazy_url($url) {
135
  if (get_option('fifu_lazy') != 'toggleon' || is_ajax_call())
136
  return 'src="' . $url . '"';
137
  return (is_home() || (class_exists('WooCommerce') && is_shop()) ? 'data-src="' : 'src="') . $url . '"';
138
  }
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) {
155
  function fifu_internal_priority() {
156
  return get_option('fifu_priority') == 'toggleon';
157
  }
158
+
159
+ function fifu_get_image_sizes() {
160
+ global $_wp_additional_image_sizes;
161
+ $sizes = array();
162
+ foreach (get_intermediate_image_sizes() as $_size) {
163
+ if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
164
+ $sizes[$_size]['width'] = get_option("{$_size}_size_w");
165
+ $sizes[$_size]['height'] = get_option("{$_size}_size_h");
166
+ $sizes[$_size]['crop'] = (bool) get_option("{$_size}_crop");
167
+ } elseif (isset($_wp_additional_image_sizes[$_size])) {
168
+ $sizes[$_size] = array(
169
+ 'width' => $_wp_additional_image_sizes[$_size]['width'],
170
+ 'height' => $_wp_additional_image_sizes[$_size]['height'],
171
+ 'crop' => $_wp_additional_image_sizes[$_size]['crop'],
172
+ );
173
+ }
174
+ }
175
+ return $sizes;
176
+ }
177
+
178
+ function fifu_get_image_size($size) {
179
+ $sizes = fifu_get_image_sizes();
180
+ if (is_array($size)) {
181
+ $arr_size = array();
182
+ $arr_size['width'] = $size[0];
183
+ $arr_size['height'] = $size[1];
184
+ return $arr_size;
185
+ }
186
+ return isset($sizes[$size]) ? $sizes[$size] : false;
187
+ }
188
+
readme.txt CHANGED
@@ -159,6 +159,9 @@ Features:
159
 
160
  == Changelog ==
161
 
 
 
 
162
  = 1.9.1 =
163
  * Premium ad: WooCommerce product variable and Tumblr video support.
164
 
@@ -390,6 +393,9 @@ was removed. To finish, a Premium version is now been presented.
390
 
391
  == Upgrade Notice ==
392
 
 
 
 
393
  = 1.9.1 =
394
  * Premium ad: WooCommerce product variable and Tumblr video support.
395
 
159
 
160
  == Changelog ==
161
 
162
+ = 1.9.2 =
163
+ * New: WooCommerce lightbox and zoom.
164
+
165
  = 1.9.1 =
166
  * Premium ad: WooCommerce product variable and Tumblr video support.
167
 
393
 
394
  == Upgrade Notice ==
395
 
396
+ = 1.9.2 =
397
+ * New: WooCommerce lightbox and zoom.
398
+
399
  = 1.9.1 =
400
  * Premium ad: WooCommerce product variable and Tumblr video support.
401