Skip to content
ProFree rules cover post type and image size. Pro adds file type, image dimensions, file size, orientation, aspect ratio, date range, post category, and (with WooCommerce) product_cat & product_tag.View pricing & buy →

Conditional rules

Most sites don't want every image watermarked. You probably want to:

  • Stamp product photos but skip avatars.
  • Watermark gallery images but leave thumbnails clean.
  • Apply only to images larger than 1000 px.
  • Different watermark for product photos than for blog images.

Conditional rules let you do all of that without writing code.

Where rules are configured

Open Watermark → Edit your template → Rules.

You'll see one or more rule rows. Each row is a single condition. Multiple rules within a watermark are AND-combined (all must match).

Click Add rule to add another condition. Click × to remove.

Free rule types

RuleWhat it matches
Post typeApply only when the image is attached to a post of this type (post, page, attachment, custom CPTs).
Image sizeApply only to specific WordPress subsizes (full, large, medium, thumbnail, …).

If you leave Image size empty, every subsize is watermarked (WatermarkHelper.php:660–662).

Pro rule types

PROGranular conditions

Pro adds file type, dimensions, file size, orientation, aspect ratio, date range, and category-based rules. With WooCommerce active, you also get product category and tag rules.

Unlock advanced rules →
RuleWhat it matches
File type (file_type)MIME type — image/jpeg, image/png, image/gif, image/webp. Skip e.g. PNG-with-alpha to avoid black backgrounds.
Image widthMatch width as is greater than, is less than, or equals (in px). Skip thumbnails.
Image heightSame operators on height.
File sizeSkip very small or very large files. Operators: >, <, = (KB / MB).
Image orientationLandscape / portrait / square.
Image aspect ratioMatch 16:9, 4:3, 1:1, custom.
Date rangeApply only to images uploaded between two dates.
Post categoryMatch parent post's category (taxonomy category).
product_cat (WC)WooCommerce product category.
product_tag (WC)WooCommerce product tag.

The full list of registered Pro condition types is in ProAdminManager.php:1017–1118.

Operators

Each rule has an operator. Available values:

OperatorMeaning
equalsExact match.
not_equalsNot this value.
containsSubstring match (string fields).
greater_thanNumeric comparison.
less_thanNumeric comparison.
inOne of a list.
not_inNone of a list.

Common rule recipes

Watermark only large images (≥ 1000 px wide)

RuleOperatorValue
Image widthgreater_than1000
RuleOperatorValue
Post typeequalsproduct
Image sizeinfull, large

Watermark JPEG and WebP, but skip PNG (transparency)

RuleOperatorValue
File typeinimage/jpeg, image/webp

Different watermark for blog vs product

Create two templates:

Template ABlog watermark

RuleOperatorValue
Post typeequalspost

Template BProduct watermark

RuleOperatorValue
Post typeequalsproduct

Each upload runs through both templates; only the matching one applies.

Watermark only photos uploaded after 2024

RuleOperatorValue
Date rangebetween2024-01-01 → today

Empty rules → apply to all

If a watermark has no rules at all, it applies to every uploaded image — subject to the image-size match in watermark_sizes (also acting as apply to all when empty).

Rule precedence vs legacy

Older versions of Ultimate Watermark used watermark_on and watermark_post_types meta directly (WatermarkHelper.php:494–519). The current build prefers unified watermark_rules:

  1. If watermark_rules is non-empty → evaluate via RulesEvaluator.
  2. If watermark_rules is empty → fall back to legacy watermark_on + sizes (WatermarkHelper.php:726–793).

You don't need to think about this unless you're migrating from a very old install — the new builder writes watermark_rules.

Custom rule types via filter

Add your own condition types by hooking uwm_condition_types (AddWatermarkPage.php:1082):

php
add_filter( 'uwm_condition_types', function ( $types ) {
    $types['custom_meta'] = [
        'label'     => 'Custom post meta',
        'operators' => [ 'equals', 'not_equals' ],
    ];
    return $types;
} );

add_filter( 'uwm_evaluate_condition', function ( $matches, $rule, $context ) {
    if ( $rule['type'] !== 'custom_meta' ) return $matches;
    $value = get_post_meta( $context['post_id'], $rule['meta_key'], true );
    return $value === $rule['value'];
}, 10, 3 );

See Hooks & filters for the full evaluator API.

Performance note

Each rule is evaluated per subsize during upload / metadata generation. Adding 10 rules per template costs ~10 × N evaluations per upload (where N = number of subsizes). For typical sites this is negligible — but if you're processing thousands of uploads in a batch, prefer fewer specific rules over many generic ones.

Where to go next