From 1202b4fd7b305b223d64f9e9f24424b72c81ab6d Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 6 Mar 2007 22:37:05 +0000 Subject: * Add preview parameter to preprocesser calls, use this rather than the previous ugly hack used to avoid writing rss feeds in previews. * Fix the img plugin to avoid overwriting images in previews. Instead it does all the work to make sure the resizing works, and dummys up a resized image using width and height attributes. * Also fixes img preview display, the links were wrong in preview before. --- IkiWiki/Plugin/img.pm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin/img.pm') diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 2a6533e39..9135c688f 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -49,7 +49,6 @@ sub preprocess (@) { #{{{ my $outfile = "$config{destdir}/$dir/${w}x${h}-$base"; $imglink = "$dir/${w}x${h}-$base"; - will_render($params{page}, $imglink); if (-e $outfile && (-M srcfile($file) >= -M $outfile)) { $r = $im->Read($outfile); @@ -62,8 +61,15 @@ sub preprocess (@) { #{{{ $r = $im->Resize(geometry => "${w}x${h}"); return "[[img failed to resize: $r]]" if $r; - my @blob = $im->ImageToBlob(); - writefile($imglink, $config{destdir}, $blob[0], 1); + # don't actually write file in preview mode + if (! $params{preview}) { + will_render($params{page}, $imglink); + my @blob = $im->ImageToBlob(); + writefile($imglink, $config{destdir}, $blob[0], 1); + } + else { + $imglink = $file; + } } } else { @@ -74,12 +80,19 @@ sub preprocess (@) { #{{{ add_depends($imglink, $params{page}); - return ''.$alt.''; } #}}} -1; +1 -- cgit v1.2.3