Users can add images to content. They're supposed to be uploading them to the site, but occasionally people will reference an image hosted elsewhere in the src='...'.

What is the best way to prevent these images from working (or even better, redirecting to a "This image is blocked" image)? I imagined using a hook of some sort to modify the content, or possibly a module that adds a filter to weed out these images. But it seems like a situation I could be overthinking.

Any suggestions?

1 Answer 1


I presume you are allowing the uploading and embedding of images via the WYSIWYG. That being the case you need to write a text filter and apply it to the text format the users are allowed to use (Filtered HTML for example). http://local.example.com/admin/config/content/formats/filtered_html

Have a look at the Examples module for how to do that.

filter_example  Defining an input filter

If you're not allowing them to upload and embed via the WYSIWYG (but uploading via a field for example) you could simply remove img from the permitted tags in your Limit allowed HTML tags filter.

  • Users are allowed to upload files via WYSIWYG, so your solution makes sense to me. Thanks! Commented Nov 8, 2013 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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