ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Brett DeWoody


You must be logged in to post.

Strip specified tags AND content?

Feature Request

Michael C.
Michael C.

I have a situation where I have a paragraph of text, with a floated image + caption inside of it:

img src="example.jpg">
figcaption>I don't want to keep this caption text</figcaption>
    This is the "real" paragraph text, which I DO want to keep.

Most tag stripping solutions would result in this:

I don't want to keep this caption textThis is the "real" paragraph text, which I DO want to keep. 

What I’d like is the ability to discard the content from specified tags. In this case, I’d want to strip all tags, as well as discard the content of any <figure> tags (but keep the content of <p> tags).

This is the "real" paragraph textwhich I DO want to keep

In case you’re wanting a use-case, I’ve got entry content in Wygwam fields, images in a Matrix, and the client is putting {image_1} / {image_2} slugs into the Wygwam field wherever the images should appear. The reason I need to omit the image captions is because I’m trying to prepare the text as an OpenGraph description for Facebook sharing, and the client obviously doesn’t need to have the image caption as the very first text to be shown in the Facebook excerpt. :p