added new image format options
Details
Preparations
In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl template add below code at the beginning of poll_element element:
<img src="<inp2:Field name='Image' format='resize:480x640;crop:100|200;quality:10;orientation:auto'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:x480;orientation:landscape'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:x480;orientation:portrait'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:640x480;output_format:png'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:5000x5000;output_format:png'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:5000x5000;output_format:jpg'/>" border="0" alt="<inp2:Field field='Question'/>"> <img src="<inp2:Field name='Image' format='resize:5000x5000'/>" border="0" alt="<inp2:Field field='Question'/>">
Testing
- Make sure In-Bulletin module is active and advanced theme is selected as default theme
- Go to Catalog & Website → Polls section
- Create poll without answers, but with big enough (more than 640x480) landscape jpg image
- Go to front-end forums.html page
- Confirm, that 1st image shown is landscape, bad quality, cropped by horizontal axis 2x more, than by vertical
- Confirm, that 2nd image shown have height 480px
- Confirm, that 3rd image shown have width 480px
- Confirm, that 4th image shown is in png format
- Confirm, that 5th image (for this to work uploaded image must be less than 5000x5000) has png extension
- Confirm, that 6th image (for this to work uploaded image must be less than 5000x5000) has jpg extension
- Confirm, that 7th image (for this to work uploaded image must be less than 5000x5000) has jpg extension
Crash testing
In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl template, in the code, added at the beginning of poll_element element, change requested format part value, refresh page and see result:
- Change quality to -5
- Confirm that exception "Quality value "-5" is out of 0..100 integer range." is thrown
- Change quality to 105
- Confirm that exception "Quality value "105" is out of 0..100 integer range." is thrown
- Change quality to 1.5
- Confirm that exception "Quality value "1.5" is out of 0..100 integer range." is thrown
- Change quality to 100
- Change output_format to tiff
- Confirm that exception "Output format value "tiff" is out of [jpg,png,gif,bmp,auto] range." is thrown
- Change output_format to png
- Change orientation to normal
- Confirm that exception "Orientation value "normal" is out of [auto,manual,portrait,landscape] range." is thrown
- Change orientation to portrait
- Where orientation is auto change resize to 480x
- Confirm that exception "Both width & height parameters must be specified." is thrown
- Where orientation is auto change resize to x640
- Confirm that exception "Both width & height parameters must be specified." is thrown
- Where orientation is auto set resize to 480x640
Diff Detail
- Repository
- rINP In-Portal
- Branch
- /in-portal/branches/5.2.x
- Lint
Lint Errors Excuse: Full file re-formatting is not part of this task. Severity Location Code Message Error core/units/helpers/image_helper.php:37 PHPCS.E.CodingStandard.Commenting.DocComment.TagValueIndent CodingStandard.Commenting.DocComment.TagValueIndent Error core/units/helpers/image_helper.php:37 PHPCS.E.CodingStandard.Commenting.FunctionComment.ParamCommentFullStop CodingStandard.Commenting.FunctionComment.ParamCommentFullStop Error core/units/helpers/image_helper.php:37 PHPCS.E.CodingStandard.Commenting.FunctionComment.ParamCommentNotCapital CodingStandard.Commenting.FunctionComment.ParamCommentNotCapital Error core/units/helpers/image_helper.php:38 PHPCS.E.CodingStandard.Commenting.DocComment.NonParamGroup CodingStandard.Commenting.DocComment.NonParamGroup Error core/units/helpers/image_helper.php:38 PHPCS.E.CodingStandard.Commenting.FunctionComment.InvalidReturn CodingStandard.Commenting.FunctionComment.InvalidReturn Error core/units/helpers/image_helper.php:38 PHPCS.E.Generic.Files.LineLength.MaxExceeded Generic.Files.LineLength.MaxExceeded Error core/units/helpers/image_helper.php:83 PHPCS.E.CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace Error core/units/helpers/image_helper.php:83 PHPCS.E.CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace Error core/units/helpers/image_helper.php:159 PHPCS.E.Generic.Files.LineLength.MaxExceeded Generic.Files.LineLength.MaxExceeded Error core/units/helpers/image_helper.php:279 PHPCS.E.CodingStandard.Commenting.InlineComment.InvalidEndChar CodingStandard.Commenting.InlineComment.InvalidEndChar Error core/units/helpers/image_helper.php:279 PHPCS.E.CodingStandard.Commenting.InlineComment.NotCapital CodingStandard.Commenting.InlineComment.NotCapital Warning core/units/helpers/image_helper.php:319 PHPCS.W.CodingStandard.PHP.NoSilencedErrors.Discouraged CodingStandard.PHP.NoSilencedErrors.Discouraged - Unit
No Unit Test Coverage - Build Status
Buildable 942 Build 942: arc lint + arc unit
Event Timeline
In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl change poll image output code to:
Please change this to:
In the `themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl` template add below code at the beginning of `poll_element` element:
Right now it's not obvious what template fragment needs to be changed.
core/units/helpers/image_helper.php | ||
---|---|---|
38–42 | Example for output_format and orientation options is missing. | |
57–59 | Not covered in test plan. | |
64–68 | Not covered in test plan. | |
73–77 | Not covered in test plan. | |
154–156 | Not covered in test plan. | |
654–660 | Please combine error messages and conditions (if either of dimensions isn't specified, then exception). |
core/units/helpers/image_helper.php | ||
---|---|---|
654–660 | There is nothing to combine. This method is called only when at least one resize dimension is specified. |
core/units/helpers/image_helper.php | ||
---|---|---|
654–660 | I've meant this change: if ( $dst_width === '' || $dst_height === '' ) { throw new InvalidArgumentException('Both width & height parameters must be specified.'); } |