> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/cms/wordpress/use-cases/wp-rocket-lazyload.md).

# Wp-rocket Lazyload

Modify attr when Lazyloading is activate on wp-rocket plugins

When lazy-loading is enabled (for example by WP Rocket), image URLs are stored in `data-lazy-src` / `data-lazy-srcset` attributes instead of `src` / `srcset`. You can tell the Weglot parser to detect and translate those attributes with the `weglot_get_dom_checkers` filter.

```php
add_filter( 'weglot_get_dom_checkers', 'weglot_dom_check_data_lazy_src' );
function weglot_dom_check_data_lazy_src( $dom_checkers ) {

	if ( ! class_exists( 'Img_Data_Lazy_Src' ) ) {
		class Img_Data_Lazy_Src extends Weglot\Parser\Check\Dom\AbstractDomChecker {
			const DOM       = 'img';
			const PROPERTY  = 'data-lazy-src';
			const WORD_TYPE = Weglot\Parser\Definitions\Enum\WordType::IMG_SRC;
		}
	}
	$dom_checkers[] = '\Img_Data_Lazy_Src';

	if ( ! class_exists( 'Source_Data_Lazy_SrcSet' ) ) {
		class Source_Data_Lazy_SrcSet extends Weglot\Parser\Check\Dom\AbstractDomChecker {
			const DOM       = 'source';
			const PROPERTY  = 'data-lazy-srcset';
			const WORD_TYPE = Weglot\Parser\Definitions\Enum\WordType::IMG_SRC;
		}
	}
	$dom_checkers[] = '\Source_Data_Lazy_SrcSet';

	return $dom_checkers;
}
```

{% hint style="info" %}
Add each class to `$dom_checkers` **outside** the `class_exists()` check: the filter can run several times in the same request (emails, PDF invoices, cart fragments), and the checker must be added every time.

Since Weglot 6.3 these classes live under `Weglot\Parser\…`. Snippets written with the older `Weglot\Client\Api\Enum\WordType` keep working.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.weglot.com/cms/wordpress/use-cases/wp-rocket-lazyload.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
