jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brus...@apache.org
Subject [1/3] jspwiki git commit: ImagePlugin : handling class/styles; caption fix
Date Sun, 12 Mar 2017 15:23:58 GMT
Repository: jspwiki
Updated Branches:
  refs/heads/master 64ffe2e49 -> aca4ab64d


ImagePlugin : handling class/styles; caption fix

2.10.3-git-35


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/2235abad
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/2235abad
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/2235abad

Branch: refs/heads/master
Commit: 2235abadb47b831e04e8ae7558d8f23e912b7607
Parents: 64ffe2e
Author: brushed <dirk.frederickx@gmail.com>
Authored: Sun Mar 12 16:22:24 2017 +0100
Committer: brushed <dirk.frederickx@gmail.com>
Committed: Sun Mar 12 16:22:24 2017 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/wiki/plugin/Image.java | 28 +++++++++++++++++---
 1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/2235abad/jspwiki-war/src/main/java/org/apache/wiki/plugin/Image.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/plugin/Image.java b/jspwiki-war/src/main/java/org/apache/wiki/plugin/Image.java
index 5ee799a..f12f1da 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/plugin/Image.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/plugin/Image.java
@@ -118,7 +118,7 @@ public class Image
             throw new PluginException("Parameter 'src' is required for Image plugin");
         }
 
-        if( cssclass == null ) cssclass = "imageplugin";
+        //if( cssclass == null ) cssclass = "imageplugin";
 
         if( target != null && !validTargetValue(target) )
         {
@@ -142,13 +142,18 @@ public class Image
 
         StringBuilder result = new StringBuilder();
 
-        result.append( "<table border=\"0\" class=\""+cssclass+"\"" );
+        result.append( "<table border=\"0\" class=\"imageplugin\"" );
         //if( align != null ) result.append(" align=\""+align+"\"");
         //if( style != null ) result.append(" style=\""+style+"\"");
 
         //
         //  Do some magic to make sure centering also work on FireFox
         //
+        if( align != null && align.equals("center") )
+        {
+            result.append(" style=\"margin-left: auto; margin-right: auto;\"");
+        }
+/*
         if( style != null )
         {
             result.append(" style=\""+style);
@@ -167,6 +172,7 @@ public class Image
         {
             if( align != null && align.equals("center") ) result.append(" style=\"margin-left:
auto; margin-right: auto;\"");
         }
+*/
 
         if( title != null ) result.append(" title=\""+title+"\"");
 
@@ -176,11 +182,25 @@ public class Image
 
         if( caption != null )
         {
-            result.append("<caption align=bottom>"+TextUtil.replaceEntities(caption)+"</caption>\n");
+            result.append("<caption>"+caption+"</caption>\n");
         }
 
+        //move css class and style to the container of the image,
+        //so it doesn't affect the caption
+        result.append( "<tr><td" );
+
+        if( cssclass != null ) result.append(" class=\""+cssclass+"\"");
+        if( style != null )
+        {
+            result.append(" style=\""+style);
+
+            // Make sure that we add a ";" to the end of the style string
+            if( result.charAt( result.length()-1 ) != ';' ) result.append(";");
+
+            result.append("\"");
+        }
 
-        result.append( "<tr><td>" );
+        result.append( ">" );
 
         if( link != null )
         {


Mime
View raw message