Check for an image in Rich Text Field I have a DIV wrapping a Rich Text field.  I would like to add a class name to the DIV only if an image is present in the text field.  Is there a way to check for an image?
You could use the in operator to search for a substring in your markup.

{% set imageExists = '&lt;img' in entry.body.getRawContent() %}
{% set classAttr = imageExists ? 'with-image' : '' %}

&lt;div class="{{ classAttr }}"&gt;
    {{ entry.body }}
&lt;/div&gt;


Another, probably bit more reliable way to test for &lt;img&gt; elements is to use the Retcon plugin, which uses DOMdocument to parse the markup.

A combination of retconOnly and length filters should get you there.

{% set imageExists = entry.body|retconOnly('img')|length %}