Saturday, October 11, 2008
Modifying the BBCode plugin in FlatPress
I like FlatPress!
I’ve found that the standard BBCode plugin does not allow to specify the “alt” tag for images.
To enable this feature I’ve modified the do_bbcode_img function, in the plugin.bbcode.php file, by expading the line:
$alt = $title = basename($actualpath);
into:
if (isset($attributes['alt'])) {
$alt = $title = htmlspecialchars($attributes['alt']);
}
else {
$alt = $title = basename($actualpath);
}
This simple modification allows me to write, for example:
[img=images/ae.png popup=true alt='My custom made image title']obtaing the following output (hover the mouse on the image) and the good side-effect, almost for free, is that the new title is also used by lightbox (click on the image):
PS: the htmlspecialchars() function is invoked to prevent the use of malicious html/javascript code by bad guys.
Add comment
Fill out the form below to add your own comments

Saturday, March 6, 2010 - 09:08:24
great trick. was quite frustrated with not being able to alter ‘title’