Skip to content

Commit eededfa

Browse files
tijmenbruggemanrkoopmans
authored andcommitted
Add documentation for filter
1 parent b2c0f4e commit eededfa

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

docs/hooks/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Hooks
2+
3+
The plugin provides several hooks to let you extend or modify its behavior.
4+
5+
## Actions
6+
7+
- [updated_tiny_postmeta](updated_tiny_postmeta.md) — Triggered when tinify meta data has been updated
8+
- [tiny_image_after_compression](tiny_image_after_compression.md) — Triggered after successful optimization.
9+
10+
## Filters
11+
12+
- [tiny_replace_with_picture](tiny_replace_with_picture.md) — Enable or disable converting `<img>` tags to `<picture>` elements.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
```

docs/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Tinify WordPress — Documentation
2+
3+
Welcome to the developer documentation of the Tinify WordPress plugin.
4+
5+
## Sections
6+
7+
- [Hooks](hooks/index.md)
8+
- [Actions](hooks/index.md#actions)
9+
- [Filters](filters/index.md#filters)

0 commit comments

Comments
 (0)