allow omission of height from image subroutine and preserve aspect ratio #316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, when calling the
image()
subroutine, omitting a height specification causes a default of 100 (px) to be used in HTML output. This changes the behavior so that when a height is not specified, it is not specified in the HTMLIMG
tag either. So the specified width (or the default width of 100) will be combined with the image's actual aspect ratio by the browser to define the width that we see.I tested with:
where the first image is a dynamically created png, and the second two images were uploaded adjacent to the .pg test file. Best to use images that do not have 1:1 aspect ratios. Then play around with adding
width=>some-number
and see if the width is respected and the aspect ratio is maintained. Then also specify height and see if that is respected.Test across browsers.
No need to test hard copy output because the code doesn't touch that.
This change in behavior should not affect OPL problems because they should have been specifying a height up to now. The only way this would change OPL problems is if there is a problem that wanted the 100 px height and was obtaining it by letting the default take hold instead of explicitly asking for 100px. And even then, there will be no bad effect unless the problem author intentionally wanted a bad aspect ratio.
The purpose of this commit is to allow authors to only specify a width when using
image()
and not worry about height.