[rt #1331] option to disable old-style image insertion
authorTony Cook <tony@develop-help.com>
Wed, 7 Mar 2012 07:04:18 +0000 (18:04 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 7 Mar 2012 07:04:18 +0000 (18:04 +1100)
It can be disabled on an article basis.

It can be disabled on a global basis.

It can be defaulted to disabled for new articles.

Life is good.

Changes.txt
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/Generate.pm
site/docs/config.pod
site/templates/admin/article_img.tmpl

index f0d3e201468bce2467165a4ee587f136a98c54d7..6541da88573da2c39824a466c2680efc17fb6840 100644 (file)
@@ -1,3 +1,10 @@
+BSE 0.22 - unreleased
+========
+
+ - automatic image insertion can now be disabled globally or on a
+   per-article basis.
+   https://rt4.develop-help.com/Ticket/Display.html?id=1331
+
 BSE 0.21 - 07 Mar 2012
 ========
 
index 1feb89fc81958a7f37ccc1b8562cc6188ac6fa38..cd7ef720dd871225624bac4b9f772a8cdd65a090 100644 (file)
@@ -15,7 +15,7 @@ use DevHelp::Date qw(dh_parse_date dh_parse_sql_date);
 use List::Util qw(first);
 use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
 
-our $VERSION = "1.022";
+our $VERSION = "1.023";
 
 =head1 NAME
 
@@ -2874,7 +2874,7 @@ sub save_image_changes {
   my $cgi = $req->cgi;
   my $image_pos = $cgi->param('imagePos');
   if ($image_pos 
-      && $image_pos =~ /^(?:tl|tr|bl|br)$/
+      && $image_pos =~ /^(?:tl|tr|bl|br|xx)$/
       && $image_pos ne $article->{imagePos}) {
     $article->{imagePos} = $image_pos;
     $article->save;
index 9c507293e105c404e55e985c3d8848c850524d30..e0cb0bf2062cb645d6d17a375efb60f0e5ef1ecc 100644 (file)
@@ -11,7 +11,7 @@ use BSE::Util::Iterate;
 use base 'BSE::ThumbLow';
 use base 'BSE::TagFormats';
 
-our $VERSION = "1.005";
+our $VERSION = "1.006";
 
 my $excerptSize = 300;
 
@@ -236,7 +236,10 @@ sub format_body {
 
   # we don't format named images
   my @images = grep $_->{name} eq '', @$images;
-  if ($auto_images && @images) {
+  if ($auto_images
+      && @images
+      && $self->{cfg}->entry('basic', 'auto_images', 1)
+      && $imagePos ne 'xx') {
     # the first image simply goes where we're told to put it
     # the imagePos is [tb][rl] (top|bottom)(right|left)
     my $align = $imagePos =~ /r/ ? 'right' : 'left';
index 6cc2883bad9fdea3b8e9239182f14fd5327754eb..4dccfe3a6e0eab0f100870b42c0ef123f07c8d5c 100644 (file)
@@ -444,6 +444,16 @@ If true, BSE will cache compiled templates using the configured BSE
 cache, if any.  Depending on the configured cache this may slow things
 down.  Default: disabled.
 
+=item auto_images
+
+By default, if the author doesn't use any image tags, BSE will insert
+any unnamed article images into the body text of an article.  You can
+disable this on a per-article basis in the image tool, or disable it
+globally by setting C<auto_images> to 0.
+
+An alternative is to set C<imagePos> in C<[article defaults]> to
+C<xx> which will default articles to not auto-inserting images.
+
 =back
 
 =head2 [mail]
index 1565697e1d4aa874a4161b1fda5367622ebbcd10..4aa7c921e6d655c5980e5c322580f7d08e380522 100644 (file)
   <h2>Manage images</h2>
 
         <table class="editform images">
-          <:if Images:><:if Eq [article id] "-1":><:or Eq:><tr> 
+          <:if Images:><:if Eq [article id] "-1":><:or Eq:><:if Cfg basic auto_images 1:><tr> 
             <th colspan="5">First Image Position</th>
           </tr>
                  <tr> 
             <td colspan="5"> 
-<input type="radio" name="imagePos" value="tl" <: ifEq [article imagePos] "tl":>checked<:or:><:eif:>
-             />Top Left &nbsp;<input type="radio" name="imagePos" value="tr"  <: ifEq [article imagePos] "tr":>checked<:or:><:eif:>
-             />Top Right &nbsp; <input type="radio" name="imagePos" value="bl"  <: ifEq [article imagePos] "bl":>checked<:or:><:eif:>
-             />Bottom Left &nbsp; <input type="radio" name="imagePos" value="br"  <: ifEq [article imagePos] "br":>checked<:or:><:eif:>
-             />Bottom Right <:help image position:>
+<input type="radio" name="imagePos" value="tl" <: ifEq [article imagePos] "tl":>checked<:eif:> />Top Left &nbsp;
+<input type="radio" name="imagePos" value="tr"  <: ifEq [article imagePos] "tr":>checked<:eif:> />Top Right &nbsp;
+<input type="radio" name="imagePos" value="bl"  <: ifEq [article imagePos] "bl":>checked<:eif:> />Bottom Left &nbsp;
+<input type="radio" name="imagePos" value="br"  <: ifEq [article imagePos] "br":>checked<:eif:> />Bottom Right
+<input type="radio" name="imagePos" value="xx"  <: ifEq [article imagePos] "xx":>checked<:eif:> />Don't automatically insert images
+
+<:help image position:>
 
            </td>
-          </tr><:eif Eq:>
+          </tr><:eif Cfg:><:eif Eq:>
 <:if Thumbs:>
           <tr> 
             <th>Image</th>