Modify attr when Lazyloading is activate on wp-rocket plugins
Override Lang attribute
You can modifiy your data-lazy-src and data-lazy-srcset attribute (or another element in dom) by using our weglot_get_dom_checkers filter
add_filter('weglot_get_dom_checkers','weglot_dom_check_data_lazy_src');function weglot_dom_check_data_lazy_src( $dom_checkers ) { //$dom_checkers contains the list of all the class we are checking by default
classImg_Data_Lazy_SrcextendsWeglot\Parser\Check\Dom\AbstractDomChecker {const DOM ='img'; //Type of tag you want to detect // CSS Selectorconst PROPERTY ='data-lazy-src'; //Name of the attribute in that tag uou want to detect const WORD_TYPE = Weglot\Client\Api\Enum\WordType::IMG_SRC; //Do not change unless it's not text but a media URL like a .pdf file for example.
} $dom_checkers[] ='\Img_Data_Lazy_Src'; //You add your class to the list because you want the parser to also detect itclassSource_Data_Lazy_SrcSetextendsWeglot\Parser\Check\Dom\AbstractDomChecker {const DOM ='source'; //Type of tag you want to detect // CSS Selectorconst PROPERTY ='data-lazy-srcset'; //Name of the attribute in that tag uou want to detect const WORD_TYPE = Weglot\Client\Api\Enum\WordType::IMG_SRC; //Do not change unless it's not text but a media URL like a .pdf file for example.
} $dom_checkers[] = '\Source_Data_Lazy_SrcSet'; //You add your class to the list because you want the parser to also detect it
return $dom_checkers ;}