Exclude images with the wrio_should_optimize filter
Use the wrio_should_optimize filter to decide whether Robin Image Optimizer processes an image in the WordPress Media Library. The filter is available in both the Free and Pro plugins and starts with true for each image or size. Return false to skip it.
The callback receives these three arguments:
| Argument | Type | Meaning |
|---|---|---|
$optimize | Boolean | Whether to process the image or size. The initial value is true; return false to skip it. |
$attachment_id | Integer | The WordPress Media Library attachment ID for the image. |
$size | String | original for the main file, or a registered generated-size name such as thumbnail. |
For example, use this filter to exclude attachment 123 from bulk and automatic processing:
<?php
add_filter( 'wrio_should_optimize', function ( $optimize, $attachment_id, $size ) {
if ( 123 === $attachment_id ) {
return false;
}
return $optimize;
}, 10, 3 );Replace 123 with the attachment ID you want to exclude. Returning the incoming $optimize value for other attachments preserves decisions made by earlier callbacks.
Bulk and automatic processing use original when checking an attachment's main file. Robin also checks generated sizes while building the file list for optimization and conversion. Returning false for a generated size leaves that size out of the list without necessarily excluding the attachment's main file or other sizes. An attachment exclusion during bulk or automatic selection does not guarantee that every explicitly started manual operation is blocked.
The $attachment_id argument refers to a Media Library attachment, not an image in a custom folder or a NextGEN gallery.
