-
-
Save markonikolic985/36d58e114474c54e56228e8bd02fbd96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Imagify: Skip <picture> Tag Replacement | |
* Description: Skip <picture> tag replacement for <img> tags that are already in <picture> tags. Just add either data-itoi-skip-picture="yes" attribute or "itoi-skip-picture" class to <img> tags that should be skipped. | |
* Version: 1.0 | |
* Author: WP Media | |
* Author URI: https://wp-media.me/ | |
* Licence: GPLv2 | |
* | |
* Copyright 2021 WP Media | |
*/ | |
| |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' ); | |
| |
add_filter( 'imagify_webp_picture_images_to_display', 'itoi_skip_picture_tag_replacement' ); | |
function itoi_skip_picture_tag_replacement( $images ) { | |
foreach ( $images as $i => $image ) { | |
if ( $image[ 'attributes' ][ 'data-itoi-skip-picture' ] === 'yes' | |
|| preg_match( '/\bitoi-skip-picture\b/', $image[ 'attributes' ][ 'class' ] ) | |
) { | |
unset( $images[ $i ] ); | |
} | |
} | |
return $images; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment