fix: Render extreme aspect ratios instead of raising - #150
Merged
Merged
Conversation
ImageSizing#fit has raised InvalidSizeOptions since #142 when a fitted size lands under a pixel, which the view helpers reach for an image far enough from square. dynamic_picture_tag goes sub-pixel at its smallest breakpoints past roughly 350:1, and dynamic_image_tag raises past the width it is asked for: size: "1200x" past 1200:1, a 50 pixel thumbnail past 50:1. Neither image rendered before #142 either, but the failure moved from one broken img to a raise in the view, so a single uploaded image takes down every page that renders it. ImageSizing#fit_renderable returns the smallest size the image can be rendered at, the whole frame scaled until its short side is one pixel, rather than raising. dynamic_image_tag and dynamic_image_url render at that size, and the tag lays the image out at the size that was asked for, so a 2000x1 image asked for "1200x" renders 2000x1 and reports a width of 1200 and a height of 1. Growing the size keeps the image's own aspect, so the frame is never cropped, and the file is never larger than the stored image: 352 bytes for a 1000x2 WebP. Picture drops the candidate widths it can't render instead, since a srcset descriptor has to match the width of the file behind it. An image too extreme for any breakpoint gets a single candidate at its own width. Requesting a size with crop: true still raises when the crop leaves less than a pixel, as does Model::Transformations#resize.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ImageSizing#fithas raisedInvalidSizeOptionssince #142 when a fitted size lands under a pixel, which the view helpers reach for an image far enough from square.dynamic_picture_taggoes sub-pixel at its smallest breakpoints past roughly 350:1, anddynamic_image_tagraises past the width it is asked for —size: "1200x"past 1200:1, a 50 pixel thumbnail past 50:1. Neither image rendered before #142 either, but the failure moved from one brokenimgto a raise in the view, so a single uploaded image takes down every page that renders it.ImageSizing#fit_renderablereturns the smallest size the image can be rendered at, the whole frame scaled until its short side is one pixel, rather than raising.dynamic_image_taganddynamic_image_urlrender at that size, and the tag lays the image out at the size that was asked for, so a 2000x1 image asked for"1200x"renders 2000x1 and reports a width of 1200 and a height of 1. Growing the size keeps the image's own aspect, so the frame is never cropped, and the file is never larger than the stored image: 352 bytes for a 1000x2 WebP.Picturedrops the candidate widths it can't render instead, since a srcset descriptor has to match the width of the file behind it. An image too extreme for any breakpoint gets a single candidate at its own width.Requesting a size with
crop: truestill raises when the crop leaves less than a pixel, as doesModel::Transformations#resize.