Links

hide-if-contains-image

The hide-if-contains-image snippet hides any HTML element (or its ancestors) that match a CSS selector if they element background image matches a given pattern.
You can use hide-if-contains-image to hide elements based on a background image or the background image of any child element.

Parameters

Name
Description
Mandatory
search
The pattern to look for in the background images of HTML elements. This must be the hexadecimal representation of the image data for which to look. If the string begins and ends with a slash (/), the text in between is treated as a regular expression.
Yes
selector
The CSS selector that an HTML element must match for it to be hidden.
Yes
searchSelector
The CSS selector that an HTML element containing the given pattern must match. Defaults to the value of the selector argument.
No

Filter examples

The following table lists examples that use the hide-if-contains snippet:
Filter
Result
hide-if-contains-image ffd8ffe1001845 div
Hides any div element whose background-image's hex matches the ffd8ffe1001845 pattern.
hide-if-contains-image /^ffd8ffe1001845/ div
Hides any div element whose background-image's hex matches the /^ffd8ffe1001845/ pattern.
hide-if-contains-image ffd8ffe1001845 .container div
Hides any .container element that has a div element whose background-image's hex matches the ffd8ffe1001845 pattern.