Skip to content

fix dropping 0x0#61

Open
Speedy1991 wants to merge 3 commits intothumbor:masterfrom
Speedy1991:fix-60
Open

fix dropping 0x0#61
Speedy1991 wants to merge 3 commits intothumbor:masterfrom
Speedy1991:fix-60

Conversation

@Speedy1991
Copy link
Copy Markdown

This will fix #60

I also added the .idea to gitignore

@Speedy1991
Copy link
Copy Markdown
Author

Btw. I think there is a lot of dead code? The Url class is never used, nor the classmethods

Comment on lines +27 to +29
has_width = bool(width)
height = options.get("height", None)
has_height = bool(height)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @Speedy1991, would it be better to use has_width = width is not None instead of has_width = bool(width)? It might handle cases like 0 more clearly.

And will be not necessary to include or 0

@Speedy1991
Copy link
Copy Markdown
Author

Speedy1991 commented Sep 2, 2025

I'll check this PR again in 1-2 weeks after my vacation. I'm still not sure if there is more refactor needed, depending the dead code

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity. Remove the stale label or add a comment, or this PR will be closed in 10 days. You can always re-open if you feel this is something we should still keep working on. Tag @heynemann for more information.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes libthumbor’s URL generation so explicitly passing width=0 and/or height=0 preserves the 0x0 dimensions segment (preventing Thumbor filters from being ignored), and updates repo ignores for IDE metadata.

Changes:

  • Treat width=0 / height=0 as explicitly provided dimensions (emit 0x0) instead of dropping the dimension segment.
  • Update Url.generate_options() defaults to None and adjust dimension appending logic accordingly.
  • Add tests for width=0 / height=0 URL composition and ignore .idea in .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
libthumbor/url.py Updates dimension handling to preserve 0x0 when explicitly requested; adjusts Url.generate_options() defaults and dimension emission.
tests/test_url_composer.py Adds regression tests for width=0 / height=0 URL generation.
.gitignore Ignores .idea directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +201 to +203
def test_url_height_0_url_with_0():
url = url_for(height=0, width=0, image_url=IMAGE_URL)
expect(url).to_equal("84996242f65a4d864aceb125e1c4c5ba")
Comment on lines 295 to +301
if horizontal_flip:
width = f"-{width}"
if vertical_flip:
height = f"-{height}"

if width or height:
url.append(f"{width}x{height}")
if width is not None or height is not None:
url.append(f"{ width or 0}x{height or 0}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug if 0x0 is used with filters

4 participants