1 I wanted to make images float left or right, so I thought it would be nice to be able to pass a class attribute through the img plugin to the final img tag.
3 An example of the feature in use can be seen here (notice class="floatleft" and class="floatright"):
7 And here's a patch to implement it. Will this survive markdown munging? It seems quite unlikely... How does one protect a block like this? Oh well, we'll see what happens.
11 From 405c29ba2ef97a514bade33ef826e71fe825962b Mon Sep 17 00:00:00 2001
12 From: Carl Worth <cworth@cworth.org>
13 Date: Wed, 23 May 2007 15:27:51 +0200
14 Subject: [PATCH] img plugin: Pass a class attribute through to the final img tag.
16 This is particularly useful for allowing the image to float.
17 For example, in my usage I use class=floatleft and then
18 in the css do .floatleft { float: left; }.
20 Plugin/img.pm | 12 +++++++++---
21 1 files changed, 9 insertions(+), 3 deletions(-)
23 diff --git a/Plugin/img.pm b/Plugin/img.pm
24 index 7226231..3eb1ae7 100644
27 @@ -93,9 +93,15 @@ sub preprocess (@) { #{{{
28 $imgurl="$config{url}/$imglink";
31 - return '<a href="'.$fileurl.'"><img src="'.$imgurl.
32 - '" alt="'.$alt.'" width="'.$im->Get("width").
33 - '" height="'.$im->Get("height").'" /></a>';
34 + my $result = '<a href="'.$fileurl.'"><img src="'.$imgurl.
35 + '" alt="'.$alt.'" width="'.$im->Get("width").
36 + '" height="'.$im->Get("height").'" ';
37 + if (exists $params{class}) {
38 + $result .= ' class="'.$params{class}.'"';
40 + $result .= '/></a>';