March 07, 2006 Archives

Tue Mar 07 6:14PM (2006)

Nanoblogger image plugin

I've written an image plugin for nanoblogger. For a given input in brackets like this:
    [imgname]

...the plugin (1) looks for a file called 'images/*imgname*.(jpg|png)', (2) generates a thumbnail, (3) gets the width/height of the thumbnail, and (4) produces a linked inline image:

    <a href="/path/to/imgname"><img src="/path/to/thumbnail" alt="(comments from EXIF)" width="XX" height="XX" /></a>

It also converts *asterisk text* to boldface, indentations to <pre>

Put this into plugins/entry/body/some-name.sh :

    export BASE_URL
    tmp=$(echo "$NB_EntryBody" | /var/www/edsantiago/blog/plugins/esm.pl)
    if [ $? -eq 0 ]; then
        if [ -n "$tmp" ]; then
            NB_EntryBody="$tmp"
        fi
    fi

...and download the actual plugin. Requires perl and the CPAN Image::Size module.


Posted by Ed | Permanent Link