X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/34e8c78c1c9bf65564c1a3086584158e5c3cc415..07a08122d926ab6b7741c94bc6c0038ffe0113fb:/IkiWiki/Plugin/attachment.pm diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 8c3ff887a..ce688ca40 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -134,9 +134,12 @@ sub formbuilder (@) { } } + $filename=IkiWiki::basename($filename); + $filename=~s/.*\\+(.+)/$1/; # hello, windows + $filename=linkpage(IkiWiki::possibly_foolish_untaint( attachment_location($form->field('page')). - IkiWiki::basename($filename))); + $filename)); if (IkiWiki::file_pruned($filename)) { error(gettext("bad attachment filename")); } @@ -195,7 +198,14 @@ sub formbuilder (@) { foreach my $f ($q->param("attachment_select")) { $f=Encode::decode_utf8($f); $f=~s/^$page\///; - $add.="[[$f]]\n"; + if (IkiWiki::isinlinableimage($f) && + UNIVERSAL::can("IkiWiki::Plugin::img", "import")) { + $add.='[[!img '.$f.' align="right" size="" alt=""]]'; + } + else { + $add.="[[$f]]"; + } + $add.="\n"; } $form->field(name => 'editcontent', value => $form->field('editcontent')."\n\n".$add, @@ -225,8 +235,7 @@ sub attachment_list ($) { my @ret; foreach my $f (values %pagesources) { if (! defined pagetype($f) && - $f=~m/^\Q$loc\E[^\/]+$/ && - -e "$config{srcdir}/$f") { + $f=~m/^\Q$loc\E[^\/]+$/) { push @ret, { "field-select" => '', link => htmllink($page, $page, $f, noimageinline => 1),