Need images etc? - check Filtered HTML

As you start creating content like a story or an article, it's easy to overlook "input formats" - where there are options for filters like Full HTML or Filtered HTML.
But these are very important; and the well-meaning Filtered HTML can trip up many a Drupal newbie: certainly caught me out, and had me searching for solution. The Filters remove HTML that isn't listed as acceptable, as website code is processed for previews or actual views, to safeguard your site from potential harm. Can set the site's default filter, plus decide which user groups have permission to use certain filters.

For me, as plenty of others, an apparently weird early problem was that I added an image to my text, but couldn't see it in Preview or web pages.

The reason: I'd left "input format" in default mode, which uses Filtered HTML. And this, by default, is so enthusiastic in stripping out potentially dangerous HTML that it also removes <img> tags. Result: no images!

One solution is to use Full HTML, so Drupal's bodyguards stand down, and all HTML code entered is allowed on actual site. This, though, is unwise if you'll have untrusted users contributing to the site.

It's better, then, to permit <img> and perhaps a few other HTML tags in Filtered HTML for untrusted users (if you're site superuser, can use Full HTML as needed).
Or, better still, create one or more new Filters: which, you'll find, can include other filters.

Creating a Filter (site configuration - input formats - add filters), you'll see that you have the option to include existing main filters, such as Filtered HTML and - depending on modules - things like a filter for menalto Gallery, and inline images filter from Image Assist.

But, in Drupal 5 at least, you can't see the HTML tags in your custom filter.
To see these, save your Custom Filter. Then, choose "configure" from the list of key filters, and then configure again.

Now, you can revise the list of tags.
At least add <img>. But since the default Filtered HTML seems like some latterday Ebeneezer Scrooge of the website world, can also add more.
As I type this, Drupal site notes: Allowed HTML tags: <h1> <h2> <h3> <h4> <h5> <h6> <em> <strong> <code> <del> <blockquote> <q> <sub> <p> <br> <ul> <ol> <li> <dl> <dt> <dd> <a> <b> <u> <i> <sup>
There's a post on TINYMCE - http://drupal.org/node/59769 - suggesting that use:
<quote><a> <em> <strong> <u> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p> <sub> <sup> <strike> <blockquote> <hr> <br></quote>
for fckeditor, a suggested list (posted by someone helping me with Filtered HTML troubles) is:
<a> <em> <strong> <small> <sup> <sub> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <h2> <h3> <h4> <img> <br> <br/> <p> <div> <span> <b> <i> <font> <color>

You'll want to leave option "strip disallowed tags".

It may be useful to create extra Filters, for finer control on users and HTML they can input.
For instance, if someone will be writing and editing articles, could allow them a wide range of tags. (If you have, say, a user group "writers n editors", might create Filtered HTML for Editors.)
But for folk who register and can just add comments, post to forum, could have tighter list. This, perhaps, could obviate need for BBcode, albeit a few fckeditor style buttons would be more user-friendly than listing of code tags.

Note that the input formats are stored as you save text etc. So if you change filter you want to be used as default for your site, won't affect saved pages.

 
 

Drupal is a registered trademark of Dries Buytaert.