It's better when it's simple

User Tools

Site Tools


ABB Syntax PlugIn

Compatible with DokuWiki


plugin Full power IMG elements for DokuWiki

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

The following security issue was reported for this extension: XSS vulnerability allows arbitrary JavaScript insertion. Author informed on 2008-02-24.

It is not recommended to use this extension until this issue was fixed. Extension authors should read the plugin security guidelines

Tagged with class, id, images

This plugin brings the full power of the the IMG-element to Dokuwiki without having to embed raw html.


The easiest use of ABB is just


where wiki:dokuwiki-128.png is the name of an image file. This will embed something like

<img src="/dokuwiki/lib/exe/fetch.php?media=wiki:dokuwiki-128.png">

into your page.

As you can see, ABB is followed by one ore more key=value pairs (called parameters) that configure the img-element.


is the only required parameter providing the URL of the image file.

As you can see, the plugin will automatically resolve the image url the DokuWiki-way so you can simply use a reference like you would for adding images with doku-wiki.

Adding more Parameters

By adding more parameters, you can add further attributes to the image-element created. To create an image with a class attribute (which can be styled by a css-handle in a central stylesheet) simply add a class=MyImageClass parameter.


To create an image with a id attribute (to be styled individually by a css-handle in a central stylesheet) simply add a id=MyImageID parameter.


To directly style you image the css-way, add a style attribute that contains your css:

~~ABB~src=wiki:dokuwiki-128.png~class=MyImageID~style=width: 30%;float: right;~~

This one sizes the image to 30% of the width of the text column and makes it float right. Please note that I kept the class-attribute so that central style-sheets can add their own css.


The plugin basically translates parameters to html-attributes. The key becomes the attribute name, the value is surrounded by quotation marks and becomes the attribute value. As exceptions to the rule, some attributes get an extra treatment:

  • src
    The URL of the image is resolved as an internal DokuWiki image.
  • title
    title attributes are processed with DokuWikis htmlspecialchars()-function
  • alt
    alt attributes are processed with DokuWikis htmlspecialchars()-function

Due to the way the parameters are processed, '=' must ony occur once to separate key from value. A '=' in the value will create unpredictable results.

Also note that the plugin does not check the validity of the resulting HTML tag. So you are entirely responsible for the havoc you create by inventing new attributes for the IMG element. :-)


It's quite easy to integrate this plugin with your DokuWiki:

  1. Download the source archive (~5KB) and un­pack it in your Doku­Wiki plug­in di­rec­to­ry {dokuwiki}/lib/plugins (make sure in­clu­ded sub­di­rec­to­ries are un­packed cor­rect­ly); this will create the directory
  2. Make sure both the new direc­tory and the files therein are read­able by the web-server e.g.
    	chown apache:apache dokuwiki/lib/plugins/* -Rc

You might as well use the plugin manager for installing and/or updating this plugin.

Plugin Source

Here comes the Apache License PHP source for those who'd like to scan it be­fore actu­ally in­stal­ling it:

|h The plugin's PHP4 source code|h
 * Plugin Abb: Full power IMG embedding"
 * @license    Apache License, Version 2.0 (
 * @author     Ferdinand Soethe <>
if (!defined('DOKU_INC'))
	define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/');
if (!defined('DOKU_PLUGIN'))
	define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'syntax.php');
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
class syntax_plugin_abb extends DokuWiki_Syntax_Plugin {
	 * return some info
	function getInfo() {
		return array (
			'author' => 'Ferdinand Soethe',
			'email' => '',
			'date' => '2007-11-11',
			'name' => 'abb - Enhanced Image Plugin',
			'desc' => 'Embed images with the full power of html img-tag',
			'url' => '',
	 * What kind of syntax are we?
	function getType() {
		return 'substition';
	 * What about paragraphs? (optional)
	function getPType() {
		return 'block';
	 * Where to sort in?
	function getSort() {
		return 999;
	 * Connect pattern to lexer
	function connectTo($mode) {
		$this->Lexer->addSpecialPattern('~~ABB.*?~~', $mode, 'plugin_abb');
	 * Handle the match
	function handle($match, $state, $pos, & $handler) {
		$resultStr = '';
		$paramsArr = explode('~', $match);
		for ($i = 0; $i < count($paramsArr); $i++) {
			$paramPairArr = explode('=', $paramsArr[$i]);
			switch ($paramPairArr[0]) {
				case 'ABB' :
				case '' :
				case 'src' :
					$resultStr .= ' src="' . ml($paramPairArr[1], '') . '"';
				case 'title' :
					$resultStr .= ' title="' . htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8') . '"';
				case 'alt' :
					$resultStr .= ' alt="' . htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8') . '"';
				default :
					$resultStr .= ' ' . $paramPairArr[0] . '="' . $paramPairArr[1] . '"';
		return '<img' . $resultStr . '>';
	 * Create output
	function render($mode, & $renderer, $data) {
		if ($mode == 'xhtml') {
			$renderer->doc .= $data; // ptype = 'normal'
			return true;
		return false;


+ initial release

Ferdinand Soethe 2007-11-12


Hints, comments, suggestions …

plugin/abb.txt · Last modified: 2011-06-18 14:14 by ach