Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-6658

The configured default image quality for scaled JPEGs is ignored

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 3.1 RC1, 3.2 M1
    • 3.1 M2
    • Other
    • None
    • Easy

    Description

      ImagePlugin defaultQuality property makes an incorrect check to see if value is Number.

      In the com.xpn.xwiki.plugin.image.ImagePlugin class under xwiki-platform-oldcore at line 127 where the class checks to see if the xwiki.plugin.image.defaultQuality paramater is a number the code uses:

      StringUtils.isNumeric(defaultQualityParam.trim())

      however, based on the documentation (and observed behavior) the method will reject any value with a dot. For example 0.5 will be rejected since the StringUtils documentation for isNumeric (http://commons.apache.org/lang/api-2.3/org/apache/commons/lang/StringUtils.html#isNumeric%28java.lang.String%29) says:

      "Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false."

      Thus the only value which is accepted will be 1.

      A way to do this would be to use FloatValidator.validate and check for null value:

      http://commons.apache.org/validator/apidocs/org/apache/commons/validator/routines/package-summary.html#package_description

      or the check could be skipped entirely since Float.parseFloat will throw an exception anyway and the system will use the default value.

      Attachments

        Activity

          People

            sdumitriu Sergiu Dumitriu
            bog.solomon Bogdan Solomon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: