A small Fundanemt Image filter

Kim Schulz, friday d. 1. september 2006

Today I got tired of not being able to having more than one image in my blog (it used the fundaNews module as backend), so I decided to create a small filter to fix this.

As with most filters, it consist of tow files (i have them placed in /fundanemt/modules/imageFilter/):

  • index.php
  • config.php

So lets get to the code:

My config.php looks like this:
  1. $filter_function = "image_filter";
  2. $filter_file = "index.php";
  3. $filter_active = true;


and the index.php is even simpler:
  1. function image_filter(&#036;str) <a href="http://<image src="]*)](.*)"([^ />" target="_top" class="normal" title="msiU", \'&lt;image src="&curren;&curren;&curren;5&curren;&curren;&curren;"&curren;&curren;&curren;6&curren;&curren;&curren; /&gt;\', &amp;#036;str);
  2. &lt;br&gt; return &amp;#036;str;
  3. &lt;br&gt;">
  4. )
  5. $str = preg_replace("</a>


So what you have now is simply a way of adding an image whereever you want an image by simply writing:
[ image PARAMS]IMAGEURL[/image] (extra space added infront of first "image" to prevent filter activation).
the PARAMS are all the parameters you want to have on your img html tag (e.g., alt="", align="right" border=0 etc.) and IMAGEURL is the full or relative url to the image your want to insert.
An example could be:
[ image alt="my House" width="100"]/some/image/myhouse.jpg[/image] which will turn into
my House

It is simple but works nicely.


Permanent url: http://www.schulz.dk/en/blog/blogarchive/50

Want your own image next to your comment? Join Gravatar.com - it's free!