PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / compatibility / class-jetpack-compatibility.php
foogallery / includes / compatibility Last commit date
elementor 7 months ago class-autoptimize-compatibility.php 7 months ago class-elasticpress-compatibility.php 7 months ago class-elementor-compatibility.php 7 months ago class-foobox-compatibility.php 7 months ago class-foogallery-compatibility.php 7 months ago class-foovideo-compatibility.php 7 months ago class-jetpack-compatibility.php 7 months ago class-polylang-compatibility.php 7 months ago class-responsive-lightbox-dfactory-compatibility.php 7 months ago class-wpoptimize-compatibility.php 7 months ago class-wprocket-compatibility.php 7 months ago view-foovideo-offer.php 7 months ago
class-jetpack-compatibility.php
64 lines
1 <?php
2 /**
3 * Jetpack Compatibility Class
4 *
5 * @since 2.0.25
6 *
7 * @package foogallery
8 */
9
10 if ( ! class_exists( 'FooGallery_Jetpack_Compatibility' ) ) {
11
12 /**
13 * Class FooGallery_Jetpack_Compatibility
14 */
15 class FooGallery_Jetpack_Compatibility {
16
17 /**
18 * FooGallery_Jetpack_Compatibility constructor.
19 */
20 public function __construct() {
21 // Add 'skip-lazy' class onto all image tags generated by FooGallery.
22 add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'add_lazy_image_attributes' ), 10, 3 );
23
24 // Add 'data' to allowed protocols.
25 // This it to overcome a conflict with JetPack lazy images, whereby JP passes all image attributes through the wp_kses_hair function
26 // This results in our image placeholder src of 'data:image/svg+xml...' being replaced with 'image/svg+xml...' which returns a 404.
27 add_filter( 'kses_allowed_protocols', array( $this, 'add_data_to_allowed_protocols' ) );
28 }
29
30 /**
31 * Adds skip-lazy class to all img tags so that they get ignored by lazy loading plugins
32 *
33 * @param array $attr the attributes.
34 * @param array $args extra arguments.
35 * @param FooGalleryAttachment $foogallery_attachment the current attachment.
36 *
37 * @return mixed
38 */
39 public function add_lazy_image_attributes( $attr, $args, $foogallery_attachment ) {
40 if ( array_key_exists( 'class', $attr ) ) {
41 $attr['class'] .= ' skip-lazy';
42 } else {
43 $attr['class'] = 'skip-lazy';
44 }
45
46 return $attr;
47 }
48
49
50 /**
51 * Add 'data' to allowed protocols.
52 *
53 * @param array $protocols existing allowed protocols.
54 *
55 * @return mixed
56 */
57 public function add_data_to_allowed_protocols( $protocols ) {
58 $protocols[] = 'data';
59
60 return $protocols;
61 }
62 }
63 }
64