Featured Image From URL - Version 3.6.9

Version Description

  • Enhancement: CDN + Optimized Thumbnails (can work with post content images now); fix: CDN + Optimized Thumbnails (conflict with images from s.yimg.com).
Download this release

Release Info

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

Code changes from version 3.6.8 to 3.6.9

admin/cli-commands.php CHANGED
@@ -256,6 +256,17 @@ class fifu_cli extends WP_CLI_Command {
256
  }
257
  return;
258
  }
 
 
 
 
 
 
 
 
 
 
 
259
  switch ($args[0]) {
260
  case 'on':
261
  update_option('fifu_photon', 'toggleon', 'no'); // toggle
256
  }
257
  return;
258
  }
259
+ if (!empty($assoc_args['content'])) {
260
+ switch ($args[0]) {
261
+ case 'on':
262
+ update_option('fifu_cdn_content', 'toggleon', 'no'); // toggle
263
+ break;
264
+ case 'off':
265
+ update_option('fifu_cdn_content', 'toggleoff', 'no'); // toggle
266
+ break;
267
+ }
268
+ return;
269
+ }
270
  switch ($args[0]) {
271
  case 'on':
272
  update_option('fifu_photon', 'toggleon', 'no'); // toggle
admin/html/menu.html CHANGED
@@ -1653,6 +1653,23 @@
1653
  on, off
1654
  </th>
1655
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1656
  <tr class="color">
1657
  <th>
1658
  <?php $fifu['tab']['performance']() ?>
@@ -4401,6 +4418,32 @@
4401
  </td>
4402
  <td><?php $fifu['jetpack']['toggle']['crop']() ?></td>
4403
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4404
  </table>
4405
  </div>
4406
 
1653
  on, off
1654
  </th>
1655
  </tr>
1656
+ <tr class="color">
1657
+ <th>
1658
+ <?php $fifu['tab']['performance']() ?>
1659
+ </th>
1660
+ <th>
1661
+ <?php $fifu['title']['jetpack']() ?>
1662
+ </th>
1663
+ <th>
1664
+ <?php $fifu['jetpack']['toggle']['content']() ?>
1665
+ </th>
1666
+ <th>
1667
+ wp fifu cdn --content &lt;toggle&gt;
1668
+ </th>
1669
+ <th>
1670
+ on, off
1671
+ </th>
1672
+ </tr>
1673
  <tr class="color">
1674
  <th>
1675
  <?php $fifu['tab']['performance']() ?>
4418
  </td>
4419
  <td><?php $fifu['jetpack']['toggle']['crop']() ?></td>
4420
  </tr>
4421
+ <tr>
4422
+ <td>
4423
+ <form
4424
+ id="fifu_form_cdn_content"
4425
+ action="javascript:void(0)"
4426
+ method="post">
4427
+
4428
+ <input
4429
+ type="submit"
4430
+ href="javascript:void(0)"
4431
+ id="fifu_toggle_cdn_content"
4432
+ onclick="invert('cdn_content')"
4433
+ name="fifu_toggle_cdn_content"
4434
+ class="<?php echo $enable_cdn_content; ?>"
4435
+ value=""
4436
+ style="display:block;border:none">
4437
+
4438
+ <input
4439
+ type="hidden"
4440
+ id="fifu_input_cdn_content"
4441
+ name="fifu_input_cdn_content"
4442
+ value="" >
4443
+ </form>
4444
+ </td>
4445
+ <td><?php $fifu['jetpack']['toggle']['content']() ?></td>
4446
+ </tr>
4447
  </table>
4448
  </div>
4449
 
admin/html/support-data.html CHANGED
@@ -23,6 +23,7 @@ Max lenght:<?php echo fifu_db_get_guid_size() ?>;
23
  Plugins:<?php echo fifu_get_plugins_list() ?>;
24
  Active plugins:<?php echo fifu_get_active_plugins_list() ?>;
25
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
 
26
  fifu_cdn_crop:<?php echo $enable_cdn_crop ?>;
27
  fifu_cdn_social:<?php echo $enable_cdn_social ?>;
28
  fifu_column_height:<?php echo $column_height ?>;
23
  Plugins:<?php echo fifu_get_plugins_list() ?>;
24
  Active plugins:<?php echo fifu_get_active_plugins_list() ?>;
25
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
26
+ fifu_cdn_content:<?php echo $enable_cdn_content ?>;
27
  fifu_cdn_crop:<?php echo $enable_cdn_crop ?>;
28
  fifu_cdn_social:<?php echo $enable_cdn_social ?>;
29
  fifu_column_height:<?php echo $column_height ?>;
admin/menu.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_decode', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean')));
4
 
5
  define('FIFU_SLUG', 'featured-image-from-url');
6
 
@@ -48,6 +48,7 @@ function fifu_support_data() {
48
  $enable_photon = get_option('fifu_photon');
49
  $enable_cdn_social = get_option('fifu_cdn_social');
50
  $enable_cdn_crop = get_option('fifu_cdn_crop');
 
51
  $enable_reset = get_option('fifu_reset');
52
  $enable_content = get_option('fifu_content');
53
  $enable_content_page = get_option('fifu_content_page');
@@ -104,6 +105,7 @@ function fifu_get_menu_html() {
104
  $enable_photon = get_option('fifu_photon');
105
  $enable_cdn_social = get_option('fifu_cdn_social');
106
  $enable_cdn_crop = get_option('fifu_cdn_crop');
 
107
  $enable_reset = get_option('fifu_reset');
108
  $enable_content = get_option('fifu_content');
109
  $enable_content_page = get_option('fifu_content_page');
@@ -205,6 +207,7 @@ function fifu_update_menu_options() {
205
  fifu_update_option('fifu_input_photon', 'fifu_photon');
206
  fifu_update_option('fifu_input_cdn_social', 'fifu_cdn_social');
207
  fifu_update_option('fifu_input_cdn_crop', 'fifu_cdn_crop');
 
208
  fifu_update_option('fifu_input_reset', 'fifu_reset');
209
  fifu_update_option('fifu_input_content', 'fifu_content');
210
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_cdn_content', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_db', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_confirm_delete_all', 'fifu_run_delete_all', 'fifu_column_height', 'fifu_decode', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean')));
4
 
5
  define('FIFU_SLUG', 'featured-image-from-url');
6
 
48
  $enable_photon = get_option('fifu_photon');
49
  $enable_cdn_social = get_option('fifu_cdn_social');
50
  $enable_cdn_crop = get_option('fifu_cdn_crop');
51
+ $enable_cdn_content = get_option('fifu_cdn_content');
52
  $enable_reset = get_option('fifu_reset');
53
  $enable_content = get_option('fifu_content');
54
  $enable_content_page = get_option('fifu_content_page');
105
  $enable_photon = get_option('fifu_photon');
106
  $enable_cdn_social = get_option('fifu_cdn_social');
107
  $enable_cdn_crop = get_option('fifu_cdn_crop');
108
+ $enable_cdn_content = get_option('fifu_cdn_content');
109
  $enable_reset = get_option('fifu_reset');
110
  $enable_content = get_option('fifu_content');
111
  $enable_content_page = get_option('fifu_content_page');
207
  fifu_update_option('fifu_input_photon', 'fifu_photon');
208
  fifu_update_option('fifu_input_cdn_social', 'fifu_cdn_social');
209
  fifu_update_option('fifu_input_cdn_crop', 'fifu_cdn_crop');
210
+ fifu_update_option('fifu_input_cdn_content', 'fifu_cdn_content');
211
  fifu_update_option('fifu_input_reset', 'fifu_reset');
212
  fifu_update_option('fifu_input_content', 'fifu_content');
213
  fifu_update_option('fifu_input_content_page', 'fifu_content_page');
admin/strings.php CHANGED
@@ -940,7 +940,10 @@ function fifu_get_strings_settings() {
940
  _e("use CDN URLs in social tags and media RSS tags", FIFU_SLUG);
941
  };
942
  $fifu['jetpack']['toggle']['crop'] = function() {
943
- _e("crop images (to keep the aspect ratio defined by theme or WordPress media settings)", FIFU_SLUG);
 
 
 
944
  };
945
 
946
  // lazy
940
  _e("use CDN URLs in social tags and media RSS tags", FIFU_SLUG);
941
  };
942
  $fifu['jetpack']['toggle']['crop'] = function() {
943
+ _e("crop featured images (to keep the aspect ratio defined by theme or WordPress media settings)", FIFU_SLUG);
944
+ };
945
+ $fifu['jetpack']['toggle']['content'] = function() {
946
+ _e("apply to content images (requires Lazy Load)", FIFU_SLUG);
947
  };
948
 
949
  // lazy
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image from URL (FIFU)
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image as featured image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
7
- * Version: 3.6.8
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
4
  * Plugin Name: Featured Image from URL (FIFU)
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image as featured image of a post or WooCommerce product. Includes Image Search, Video, Social Tags, SEO, Lazy Load, Gallery, Automation etc.
7
+ * Version: 3.6.9
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
includes/jetpack.php CHANGED
@@ -1,7 +1,23 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function fifu_jetpack_blocked($url) {
4
- $blocklist = array('amazon-adsystem.com', 'sapo.io', 'unsplash.com');
5
  foreach ($blocklist as $domain) {
6
  if (strpos($url, $domain) !== false)
7
  return true;
1
  <?php
2
 
3
+ define('FIFU_JETPACK_SIZES', serialize(array(75, 100, 150, 240, 320, 500, 640, 800, 1024, 1280, 1600)));
4
+
5
+ function fifu_resize_jetpack_image_size($size, $url) {
6
+ $size = (int) $size;
7
+ return "{$url}?w={$size}&resize={$size}";
8
+ }
9
+
10
+ function fifu_jetpack_get_set($url, $is_slider) {
11
+ $quality = $is_slider ? 1.25 : 1;
12
+ $set = '';
13
+ $count = 0;
14
+ foreach (unserialize(FIFU_JETPACK_SIZES) as $i)
15
+ $set .= (($count++ != 0) ? ', ' : '') . fifu_resize_jetpack_image_size($i * $quality, $url) . ' ' . $i . 'w';
16
+ return $set;
17
+ }
18
+
19
  function fifu_jetpack_blocked($url) {
20
+ $blocklist = array('amazon-adsystem.com', 'sapo.io', 'unsplash.com', 'i.guim.co.uk', 's.yimg.com', 'www.washingtonpost.com', 'pbs.twimg.com', 'ca-times.brightspotcdn.com', 'www.aljazeera.com');
21
  foreach ($blocklist as $domain) {
22
  if (strpos($url, $domain) !== false)
23
  return true;
includes/thumbnail.php CHANGED
@@ -172,6 +172,31 @@ function fifu_add_to_content($content) {
172
  return is_singular() && has_post_thumbnail() && ((is_singular('post') && fifu_is_on('fifu_content')) || (is_singular('page') && fifu_is_on('fifu_content_page')) || (fifu_is_cpt() && fifu_is_on('fifu_content_cpt'))) ? get_the_post_thumbnail() . $content : $content;
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  function fifu_should_hide() {
176
  if (class_exists('WooCommerce') && is_product())
177
  return false;
172
  return is_singular() && has_post_thumbnail() && ((is_singular('post') && fifu_is_on('fifu_content')) || (is_singular('page') && fifu_is_on('fifu_content_page')) || (fifu_is_cpt() && fifu_is_on('fifu_content_cpt'))) ? get_the_post_thumbnail() . $content : $content;
173
  }
174
 
175
+ add_filter('the_content', 'fifu_optimize_content');
176
+
177
+ function fifu_optimize_content($content) {
178
+ if (fifu_is_off('fifu_cdn_content') || empty($content))
179
+ return $content;
180
+
181
+ $srcType = "src";
182
+ $imgList = array();
183
+ preg_match_all('/<img[^>]*>/', $content, $imgList);
184
+
185
+ foreach ($imgList[0] as $imgItem) {
186
+ preg_match('/(' . $srcType . ')([^\'\"]*[\'\"]){2}/', $imgItem, $src);
187
+ if (!$src)
188
+ continue;
189
+ $del = substr($src[0], - 1);
190
+ $url = fifu_normalize(explode($del, $src[0])[1]);
191
+ $new_url = fifu_jetpack_photon_url($url, null);
192
+ $newImgItem = str_replace($url, $new_url, html_entity_decode($imgItem));
193
+ $srcset = fifu_jetpack_get_set($new_url, false);
194
+ $newImgItem = str_replace(' src=', ' class="lazyload" data-sizes="auto" data-srcset="' . $srcset . '" data-src=', $newImgItem);
195
+ $content = str_replace($imgItem, $newImgItem, $content);
196
+ }
197
+ return $content;
198
+ }
199
+
200
  function fifu_should_hide() {
201
  if (class_exists('WooCommerce') && is_product())
202
  return false;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
4
  Tags: featured, image, url, video, woocommerce
5
  Requires at least: 5.3
6
  Tested up to: 5.8
7
- Stable tag: 3.6.8
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -224,20 +224,20 @@ Featured Image, Figurë e Zgjedhur, Image mise en avant, Uitgelichte afbeelding,
224
 
225
  == Changelog ==
226
 
 
 
 
227
  = 3.6.8 =
228
  * Enhancement: Auto set featured image using web page address (can work with videos now); fix: Default Featured Image (images not being displayed).
229
 
230
  = 3.6.7 =
231
  * New feature: Disable right-click; new options for CDN + Optimized Thumbnails: use CDN URLs in social tags and media RSS tags, crop images (to keep the aspect ratio defined by theme or WordPress media settings).
232
 
233
- = 3.6.6 =
234
- * Enhancement: keyword image search (multiple suggestions, infinite scroll and integration with Quick Edit); enhancement: CDN + Optimized Thumbnails (does not require Jetpack plugin anymore).
235
-
236
  = others =
237
  * [more](https://fifu.app/changelog)
238
 
239
 
240
  == Upgrade Notice ==
241
 
242
- = 3.6.8 =
243
- * Enhancement: Auto set featured image using web page address (can work with videos now); fix: Default Featured Image (images not being displayed).
4
  Tags: featured, image, url, video, woocommerce
5
  Requires at least: 5.3
6
  Tested up to: 5.8
7
+ Stable tag: 3.6.9
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
224
 
225
  == Changelog ==
226
 
227
+ = 3.6.9 =
228
+ * Enhancement: CDN + Optimized Thumbnails (can work with post content images now); fix: CDN + Optimized Thumbnails (conflict with images from s.yimg.com).
229
+
230
  = 3.6.8 =
231
  * Enhancement: Auto set featured image using web page address (can work with videos now); fix: Default Featured Image (images not being displayed).
232
 
233
  = 3.6.7 =
234
  * New feature: Disable right-click; new options for CDN + Optimized Thumbnails: use CDN URLs in social tags and media RSS tags, crop images (to keep the aspect ratio defined by theme or WordPress media settings).
235
 
 
 
 
236
  = others =
237
  * [more](https://fifu.app/changelog)
238
 
239
 
240
  == Upgrade Notice ==
241
 
242
+ = 3.6.9 =
243
+ * Enhancement: CDN + Optimized Thumbnails (can work with post content images now); fix: CDN + Optimized Thumbnails (conflict with images from s.yimg.com).