Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for requested image dimensions while preventing percentage errors #1083

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

hudajkhan
Copy link
Contributor

@hudajkhan hudajkhan commented Dec 12, 2023

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:

  • Re-applies the original logic for handling image size requests that are larger than the original image dimensions by returning the original size dimensions instead.
  • Re-adds test for the case where the requested dimensions are larger than the original
  • When the "use_original_size?" method is called, this method will return false if the region is a percent type.
  • Within "use_original_size?", adds a rescue block for any other errors that may be thrown by region_dimensions and returns false by default for that situation, as well as doing a honeybadger notification.
  • Adds test for the "use_original_size?" methods to ensure it returns false for percent region and checks for a few other conditions.

@jcoyne jcoyne merged commit b52b26b into main Dec 13, 2023
2 checks passed
@jcoyne jcoyne deleted the handleImageSizeAndPercentage branch December 13, 2023 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken image when viewing player in Chrome
2 participants