How do I stop specific images from being optimized?

2 min read · Last updated June 2026

Add a keyword to Custom exclusions in the settings, and SlashImage skips any image whose filename or URL contains it.

Add an exclusion

  1. Go to Media > SlashImage and open the Settings tab.
  2. In the Image Size Exclusions section, find Custom exclusions and click Edit Exclusions to open the editor.
  3. Type one pattern per line, for example logo on one line and favicon on the next.
  4. Close the editor, then click Save changes on the settings page.

How matching works

  • A pattern matches as plain text anywhere inside the filename or the URL, so logo skips logo.png, site-logo-2x.jpg, and anything in a /logos/ folder.
  • Matching is case-insensitive: Logo, logo, and LOGO behave the same.
  • You can add up to 100 patterns, each up to 200 characters long.

Check it worked

An excluded image shows Excluded (matches: <pattern>) in the SlashImage Media Library column, naming the pattern that caught it. See What does the SlashImage column show?.

For developers

To decide exclusions in code, use the filter (it runs after the Custom exclusions patterns):

php
apply_filters( 'slash_image_should_skip_attachment', false, $attachment_id, $filename, $url )

Return true to skip the attachment, or a non-empty string to skip it and show that string as the matched pattern. See Actions and filters for developers.

See also

Was this helpful?