This text filter rewrites the src
attribute on img
tags that only specify a filename to point at the current location of an attached image with the same filename should one exist.
That is, if you put this:
<img src="zebra.jpg"/>
And you've uploaded a file called zebra.jpg
to an image field on the same entity, the module will replace it with something like:
<img src="/sites/foo.com/zebra.jpg"/>
I find this works quite well with Markdown. I can usually remember the filenames or know what I'll call them when I get around to uploading. From there, ![alt text](zebra.jpg)
is pretty handy.
Why?
My hope is to improve on other methods of placing images in-line which, so far as I can tell, fall into two categories:
- Bypassing Drupal entirely and using a JS file manager of some sort to upload images directly and then referring to them in
img
tags with /sites/brittle_path/files/image.jpg
- Using a magic token that refers to the field id and often encodes some position, style, etc.
I like my images being available to Drupal. Not just pointed at in code but rendered as a field, with different Image Styles, that can be included in Views, change with Context, etc. Rules out the first one.