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

Fix API image URL generation for max width #36

Merged
merged 2 commits into from
May 9, 2024

Conversation

driftingly
Copy link
Contributor

@driftingly driftingly commented May 7, 2024

This PR fixes an issue with API image URLs when the provided image is below the preferred image dimensions.

Even though we were setting the width correctly for the width key, the URL was still being generated with the preferred width.

Before:

"img": {
"url": "https://www.artic.edu/iiif/2/c2915980-ee1f-0b74-989c-f235806486b6/full/1686,/0/default.jpg",
"width": 1605,
"height": 2250
},

After:

"img": {
"url": "https://www.artic.edu/iiif/2/c2915980-ee1f-0b74-989c-f235806486b6/full/1605,/0/default.jpg",
"width": 1605,
"height": 2250
},

I also cleaned up some uses of the spread operator to make it a bit more readable.

@@ -62,15 +65,15 @@ private function getOverrideImages(array $image): array
),
],
'img_medium' => [
'url' => $image['original'].'?fm=jpg&q=80&fit=max&dpr=1&w=843',
'url' => $image['original'].'?fm=jpg&q=80&fit=max&dpr=1&w='.static::IMAGE_SIZES['medium'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Copy link
Member

@nikhiltri nikhiltri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! ⭐

Copy link

sonarqubecloud bot commented May 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@driftingly driftingly merged commit 29c572a into develop May 9, 2024
2 checks passed
@driftingly driftingly deleted the drift/fix-image-max-for-real branch May 9, 2024 19:59
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.

3 participants