]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/attachment.pm
attachment: When inserting links, insert img directives for images, if that plugin...
[ikiwiki.git] / IkiWiki / Plugin / attachment.pm
index cbe6efc216c07de84ff547c7edbc296a76c1d146..9c774557fdbb649b010da4f899d6089f943b5337 100644 (file)
@@ -19,6 +19,7 @@ sub getsetup () {
                plugin => {
                        safe => 1,
                        rebuild => 0,
+                       section => "web",
                },
                allowed_attachments => {
                        type => "pagespec",
@@ -136,7 +137,7 @@ sub formbuilder (@) {
                $filename=linkpage(IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
                                IkiWiki::basename($filename)));
-               if (IkiWiki::file_pruned($filename, $config{srcdir})) {
+               if (IkiWiki::file_pruned($filename)) {
                        error(gettext("bad attachment filename"));
                }
                
@@ -194,7 +195,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,
@@ -224,8 +232,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" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
                                link => htmllink($page, $page, $f, noimageinline => 1),