@register.filter<EOL>def strip_oembeds(text, args=None):
resource_type = width = height = None<EOL>if args:<EOL><INDENT>dimensions = args.lower().split('<STR_LIT:x>')<EOL>if len(dimensions) in (<NUM_LIT:3>, <NUM_LIT:1>):<EOL><INDENT>resource_type = dimensions.pop()<EOL><DEDENT>if len(dimensions) == <NUM_LIT:2>:<EOL><INDENT>width, height = map(lambda x: int(x), dimensions)<EOL><DEDENT><DEDENT>client = OEmbedConsumer()<EOL>return mark_safe(client.strip(text, width, height, resource_type))<EOL>
Take a block of text and strip all the embeds from it, optionally taking
a maxwidth, maxheight / resource_type

Usage:
{{ post.content|strip_embeds }}

{{ post.content|strip_embeds:"600x600xphoto" }}

{{ post.content|strip_embeds:"video" }}