]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/img_plugin_should_pass_through_class_attribute.mdwn
bug responses
[ikiwiki.git] / doc / bugs / img_plugin_should_pass_through_class_attribute.mdwn
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.
2
3 An example of the feature in use can be seen here (notice class="floatleft" and class="floatright"):
4
5         http://www.cworth.org/
6
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.
8
9 > thanks, [[done]] --[[Joey]]
10
11 -Carl
12
13     From 405c29ba2ef97a514bade33ef826e71fe825962b Mon Sep 17 00:00:00 2001
14     From: Carl Worth <cworth@cworth.org>
15     Date: Wed, 23 May 2007 15:27:51 +0200
16     Subject: [PATCH] img plugin: Pass a class attribute through to the final img tag.
17     
18     This is particularly useful for allowing the image to float.
19     For example, in my usage I use class=floatleft and then
20     in the css do .floatleft { float: left; }.
21     ---
22      Plugin/img.pm |   12 +++++++++---
23      1 files changed, 9 insertions(+), 3 deletions(-)
24     
25     diff --git a/Plugin/img.pm b/Plugin/img.pm
26     index 7226231..3eb1ae7 100644
27     --- a/Plugin/img.pm
28     +++ b/Plugin/img.pm
29     @@ -93,9 +93,15 @@ sub preprocess (@) {
30                     $imgurl="$config{url}/$imglink";
31             }
32      
33     -       return '<a href="'.$fileurl.'"><img src="'.$imgurl.
34     -               '" alt="'.$alt.'" width="'.$im->Get("width").
35     -               '" height="'.$im->Get("height").'" /></a>';
36     +        my $result = '<a href="'.$fileurl.'"><img src="'.$imgurl.
37     +            '" alt="'.$alt.'" width="'.$im->Get("width").
38     +            '" height="'.$im->Get("height").'" ';
39     +        if (exists $params{class}) {
40     +            $result .= ' class="'.$params{class}.'"';
41     +        }
42     +        $result .= '/></a>';
43     +
44     +        return $result;
45      }
46      
47      1
48     -- 
49     1.5.1.gee969