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-wpoptimize-compatibility.php
47 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WP Optimize Compatibility Class |
| 4 | * |
| 5 | * @since 2.0.27 |
| 6 | * |
| 7 | * @package foogallery |
| 8 | */ |
| 9 | |
| 10 | if ( ! class_exists( 'FooGallery_WPOptimize_Compatibility' ) ) { |
| 11 | |
| 12 | /** |
| 13 | * Class FooGallery_WPOptimize_Compatibility |
| 14 | */ |
| 15 | class FooGallery_WPOptimize_Compatibility { |
| 16 | |
| 17 | /** |
| 18 | * FooGallery_WPOptimize_Compatibility constructor. |
| 19 | */ |
| 20 | public function __construct() { |
| 21 | // Add 'no-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 | |
| 25 | /** |
| 26 | * Adds skip-lazy class to all img tags so that they get ignored by lazy loading plugins |
| 27 | * |
| 28 | * @param array $attr the attributes. |
| 29 | * @param array $args extra arguments. |
| 30 | * @param FooGalleryAttachment $foogallery_attachment the current attachment. |
| 31 | * |
| 32 | * @return mixed |
| 33 | */ |
| 34 | public function add_lazy_image_attributes( $attr, $args, $foogallery_attachment ) { |
| 35 | if ( class_exists( 'WP_Optimize_Lazy_Load' ) ) { |
| 36 | if ( array_key_exists( 'class', $attr ) ) { |
| 37 | $attr['class'] .= ' no-lazy'; |
| 38 | } else { |
| 39 | $attr['class'] = 'no-lazy'; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return $attr; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 |