Skip to content

Fix resize function when only one dimension is passed#12

Open
jwhulette wants to merge 2 commits intostoryblok:masterfrom
jwhulette:fix-resize-using-only-one-dimension
Open

Fix resize function when only one dimension is passed#12
jwhulette wants to merge 2 commits intostoryblok:masterfrom
jwhulette:fix-resize-using-only-one-dimension

Conversation

@jwhulette
Copy link
Copy Markdown

@jwhulette jwhulette commented Mar 19, 2026

This pull request updates the behavior of the resize method in the Image class and its associated tests. The main change is that when either the width or height is set to zero, the method now sets the corresponding dimension to zero instead of calculating it to preserve the original aspect ratio. This simplifies the logic and makes the method's behavior more explicit when a zero value is provided.

Key changes:

Image resizing logic:

  • Updated the resize method in Image.php so that if either width or height is zero, the dimension is set to zero directly, rather than automatically calculating it to maintain the aspect ratio.

Test adjustments:

  • Modified the test cases in ImageTest.php to reflect the new behavior: resizing with a zero width or height now results in a dimension of zero, not a calculated value based on the original aspect ratio.

@OskarStark OskarStark changed the title Fix resize function when only one dimension is passed. Fix resize function when only one dimension is passed Mar 19, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.39%. Comparing base (36e088c) to head (0a0a4fc).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #12      +/-   ##
============================================
- Coverage     99.39%   99.39%   -0.01%     
  Complexity       54       54              
============================================
  Files             1        1              
  Lines           165      164       -1     
============================================
- Hits            164      163       -1     
  Misses            1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jwhulette
Copy link
Copy Markdown
Author

@OskarStark I have updated my PR to follow the APi conventions, https://www.storyblok.com/docs/api/image-service/operations/resize#proportional

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.

2 participants