Don't generate empty title attributes, etc, and allow setting defaults for class and id too.
parent
f6b47b0d1c
commit
ecfb14f7d1
|
@ -17,21 +17,20 @@ sub preprocess (@) { #{{{
|
||||||
my ($image) = $_[0] =~ /$config{wiki_file_regexp}/; # untaint
|
my ($image) = $_[0] =~ /$config{wiki_file_regexp}/; # untaint
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
|
|
||||||
if (! exists $imgdefaults{$params{page}}) {
|
if (exists $imgdefaults{$params{page}}) {
|
||||||
$imgdefaults{$params{page}} = {};
|
foreach my $key (keys %{$imgdefaults{$params{page}}}) {
|
||||||
|
if (! exists $params{$key}) {
|
||||||
|
$params{$key}=$imgdefaults{$params{page}}->{$key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! exists $params{size}) {
|
||||||
|
$params{size}='full';
|
||||||
}
|
}
|
||||||
my $size = $params{size} || $imgdefaults{$params{page}}->{size} || 'full';
|
|
||||||
my $alt = $params{alt} || $imgdefaults{$params{page}}->{alt} || '';
|
|
||||||
my $title = $params{title} || $imgdefaults{$params{page}}->{title} || '';
|
|
||||||
my $caption = $params{caption} || $imgdefaults{$params{page}}->{caption} || '';
|
|
||||||
|
|
||||||
if ($image eq 'defaults') {
|
if ($image eq 'defaults') {
|
||||||
$imgdefaults{$params{page}} = {
|
$imgdefaults{$params{page}} = \%params;
|
||||||
size => $size,
|
|
||||||
alt => $alt,
|
|
||||||
title => $title,
|
|
||||||
caption => $caption,
|
|
||||||
};
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +51,9 @@ sub preprocess (@) { #{{{
|
||||||
my $imglink;
|
my $imglink;
|
||||||
my $r;
|
my $r;
|
||||||
|
|
||||||
if ($size ne 'full') {
|
if ($params{size} ne 'full') {
|
||||||
my ($w, $h) = ($size =~ /^(\d+)x(\d+)$/);
|
my ($w, $h) = ($params{size} =~ /^(\d+)x(\d+)$/);
|
||||||
return "[[img ".sprintf(gettext('bad size "%s"'), $size)."]]"
|
return "[[img ".sprintf(gettext('bad size "%s"'), $params{size})."]]"
|
||||||
unless (defined $w && defined $h);
|
unless (defined $w && defined $h);
|
||||||
|
|
||||||
my $outfile = "$config{destdir}/$dir/${w}x${h}-$base";
|
my $outfile = "$config{destdir}/$dir/${w}x${h}-$base";
|
||||||
|
@ -106,9 +105,10 @@ sub preprocess (@) { #{{{
|
||||||
}
|
}
|
||||||
|
|
||||||
my $imgtag='<img src="'.$imgurl.
|
my $imgtag='<img src="'.$imgurl.
|
||||||
'" alt="'.$alt.'" width="'.$im->Get("width").
|
'" alt="'.(exists $params{alt} ? $params{alt} : '').
|
||||||
|
'" width="'.$im->Get("width").
|
||||||
'" height="'.$im->Get("height").'"'.
|
'" height="'.$im->Get("height").'"'.
|
||||||
(defined $title ? ' title="'.$title.'"' : '').
|
(exists $params{title} ? ' title="'.$params{title}.'"' : '').
|
||||||
(exists $params{class} ? ' class="'.$params{class}.'"' : '').
|
(exists $params{class} ? ' class="'.$params{class}.'"' : '').
|
||||||
(exists $params{id} ? ' id="'.$params{id}.'"' : '').
|
(exists $params{id} ? ' id="'.$params{id}.'"' : '').
|
||||||
' />';
|
' />';
|
||||||
|
@ -126,9 +126,9 @@ sub preprocess (@) { #{{{
|
||||||
noimageinline => 1);
|
noimageinline => 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $caption) {
|
if (exists $params{caption}) {
|
||||||
return '<table class="img">'.
|
return '<table class="img">'.
|
||||||
'<caption>'.$caption.'</caption>'.
|
'<caption>'.$params{caption}.'</caption>'.
|
||||||
'<tr><td>'.$imgtag.'</td></tr>'.
|
'<tr><td>'.$imgtag.'</td></tr>'.
|
||||||
'</table>';
|
'</table>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
ikiwiki (2.50) UNRELEASED; urgency=low
|
ikiwiki (2.50) UNRELEASED; urgency=low
|
||||||
|
|
||||||
* img: Support captions.
|
* img: Support captions.
|
||||||
|
* img: Don't generate empty title attributes, etc.
|
||||||
|
* img: Allow setting defaults for class and id too.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 07 Jun 2008 23:04:00 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 07 Jun 2008 23:04:00 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue