tiny_replace_with_picture.md
28 lines
| 1 | # tiny_replace_with_picture |
| 2 | |
| 3 | Filter that allows you to skip converting page content `<img>` tags into `<picture>` elements. Returning `false` disables the feature completely for that request. |
| 4 | The filter will fire on `init` with a default priority of `10`. Register your filter during or before `init` with a smaller priority than `10` to take effect. |
| 5 | |
| 6 | **Location:** `src/class-tiny-plugin.php` |
| 7 | **Since:** 3.7.0 |
| 8 | |
| 9 | ## Arguments |
| 10 | |
| 11 | 1. `bool $should_replace` — boolean to control wether `<img>` elements on the page should be replaced by `<picture>` elements if they have an optimized version. Defaults to true. Return `false` to skip all `<picture>` replacements. |
| 12 | |
| 13 | ## Example |
| 14 | |
| 15 | ```php |
| 16 | add_filter( |
| 17 | 'tiny_replace_with_picture', |
| 18 | function ( $should_replace ) { |
| 19 | // Disable picture replacement on RSS feeds. |
| 20 | if ( is_feed() ) { |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | return $should_replace; |
| 25 | } |
| 26 | ); |
| 27 | ``` |
| 28 |