I'm trying to create a rule using Rules that will apply a watermark to an image within a node (using the ImageCache Actions module) if that given node has a specific Taxonomy term. For example, nodes with the term "Video" will get a play button icon over their image.

Is there a way to add taxonomy terms as a condition in Rules? It seems like it would be a simple task but I can't seem to figure it out. Does anyone know how I could do this?

  • 1
    A rule will trigger only after an event but here you do not have any event. you are having only the condition. Jan 8, 2015 at 5:19
  • Could the event "before saving content" work?
    – Sam
    Jan 8, 2015 at 5:32
  • may be you can try before and after both situation. Jan 8, 2015 at 6:01
  • 1
    Its doable but it will be painful. Check out Conditional Rules to assist you if you need more advanced Rules logic. If I was you I would implement template_preprocess_node, check the value of the taxonomy term, and wrap image with a div that has a class on it, then style with CSS. And should you not rather try to switch out the image formatter with your Rules approach to a formatter that includes watermarking? Jan 8, 2015 at 11:41

1 Answer 1


Have a look at this, rather basic, rule (in Rules export format):

{ "rules_check_taxonomy_term" : {
    "LABEL" : "Check Taxonomy Term",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_tags" } },
      { "list_contains" : { "list" : [ "node:field-tags" ], "item" : "21" } }
    "DO" : [
      { "drupal_message" : { "message" : "A node containing the tag [node:field_tags] just got created or updated." } }

Here is what this rule does:

  • Rules Event: After saving new content, After updating existing content
  • Rules Conditions:

    • Entity has field "field_tags", which is the machine name of the term reference field I want to check for.
    • List contains item "node:field-tags" and with Taxonomy term identifier value "21" (which is the term id of the term I want to check in this Rules Condition).
  • Rules Action: Show a message on the site (which is "A node containing the tag [node:field_tags] just got created or updated." (with [node:field_tags] the actual term with term id = 21).

What is crucial in the above rules example in the context of this question, are the 2 Rules Conditions.

Use the Rules UI to import the above rule in your site. Here are the tweaks you'll need to make it fit your case:

  • Replace the Rules Event (if needed).
  • Within the Rules Conditions, perform these changes:

    • replace the "node" entity with your entity.
    • replace the machine name of term reference "field_tags", and adapt the "term id" to fit your case (for the term "Video").
  • Replace the Rules Action by whatever fits your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.