Checking for requested image dimensions while preventing percentage errors #1083
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.
Closes #1082 and sul-dlss/sul-embed#1949.
Context:
We had to revert an earlier commit for asking the IIIF server for the original size of an image when the requested dimensions were larger than the original image size: #1070 . With this original change, requests for percentage regions were resulting in an error documented here: #1069 . e.g. when the request looks like https://stacks.stanford.edu/image/iiif/cp798vs8827/6855100/pct:3,3,77,77/full/0/default.jpg .
Explanation of error:
As part of the original changes, we added a check for "use_original_size?" in the real_transformation method. This check executed "max_tile_dimensions" on the image object which in turn executes "region_dimensions" in projection.rb. This last method will raise an error for a percent region request. With the original change, this error was being thrown whenever the percent region URLs were requested, resulting in the page not loading correctly.
For reference, see https://github.com/sul-dlss/stacks/blob/main/app/models/stacks_image.rb#L43 and https://github.com/sul-dlss/stacks/blob/main/app/models/projection.rb#L32 .
What this pull request does: