Package: ikiwiki
Version: 2.3
Severity: wishlist
Tags: patch

Hi,

currently images included with the image plugin always provide a link to
the image. Sometimes this may not be needed, it may be enough to just
show the image. Currently one has to use HTML to do that.

Possible patch, using a 'link="no"' parameter to implement this:

diff --git a/img.pm b/img.pm
index a453a49..6281896 100644
--- a/img.pm
+++ b/img.pm
@@ -23,6 +23,12 @@ sub preprocess (@) { #{{{
        my $size = $params{size} || $imgdefaults{$params{page}}->{size} || 
'full';
        my $alt = $params{alt} || $imgdefaults{$params{page}}->{alt} || '';
 
+       $params{link} = 'yes' unless exists($params{link});
+       my $link = 'yes';
+       if ($params{link} eq 'no') {
+               $link = 'no';
+       }
+
        if ($image eq 'defaults') {
                $imgdefaults{$params{page}} = {
                        size => $size,
@@ -96,12 +102,22 @@ sub preprocess (@) { #{{{
                return "[[img ".sprintf(gettext("failed to determine size of 
image %s"), $file)."]]";
        }
 
-       return '<a href="'.$fileurl.'"><img src="'.$imgurl.
-               '" alt="'.$alt.'" width="'.$im->Get("width").
-               '" height="'.$im->Get("height").'"'.
-               (exists $params{class} ? ' class="'.$params{class}.'"' : '').
-               (exists $params{id} ? ' id="'.$params{id}.'"' : '').
-               ' /></a>';
+       if ($link eq 'no') {
+               return '<img src="'.$imgurl.
+                       '" alt="'.$alt.'" width="'.$im->Get("width").
+                       '" height="'.$im->Get("height").'"'.
+                       (exists $params{class} ? ' class="'.$params{class}.'"' 
: '').
+                       (exists $params{id} ? ' id="'.$params{id}.'"' : '').
+                       ' />';
+       }
+       else {
+               return '<a href="'.$fileurl.'"><img src="'.$imgurl.
+                       '" alt="'.$alt.'" width="'.$im->Get("width").
+                       '" height="'.$im->Get("height").'"'.
+                       (exists $params{class} ? ' class="'.$params{class}.'"' 
: '').
+                       (exists $params{id} ? ' id="'.$params{id}.'"' : '').
+                       ' /></a>';
+       }
 } #}}}
 
 1



Thanks,
 Nis


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to