Skip to content

Conversation

@GeKorm
Copy link
Contributor

@GeKorm GeKorm commented Nov 10, 2025

In Imgix, the type for auto is incorrect. As the doc comment says, it can be a combination of values

* @example "format,compress"

All combinations are permitted in this PR, including some which are nonsensical but still valid format,format,format,format. However, these are still valid imgix URLs.

One complication might be this line:

url.searchParams.has("fm") && url.searchParams.get("auto") === "format"

Imgix has its own logic to handle auto=format and fm=, which unpic overrides above. Should I update this to handle cases like auto=compress,format as well, or is it OK to fall back to Imgix's handling?

@ascorbic
Copy link
Owner

Thanks. I reckon it's best we let imgix handle its own logic there, and we should just pass through the options unchanged.

toUrl,
} from "../utils.ts";

type Auto = "true" | "format" | "compress" | "enhance" | "redeye";
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should allow boolean true here too. I won't block on that, because it should also have runtime handling, but it would be a good thing to have as a follow-up.

Copy link
Contributor Author

@GeKorm GeKorm Nov 10, 2025

Choose a reason for hiding this comment

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

That's how I did it initially, but in the end I felt it could be confusing.

0 <Image />
1 <Image auto />
2 <Image auto="compress" />
3 <Image auto="true,compress" />
4 <Image auto="format" />

Without digging into how it works I expected that (1) would be implied in (2) as a truthy value, but it needs to be explicit like in (3). What's more, if omitted (0) it kinda breaks the convention with booleans being falsy by default, when in reality the default is (4) auto="format".

Despite all this, I don't have a particularly strong opinion about it. It should be fine, as long as it's documented with @default and a short explanation. I'd like to open a follow-up Imgix PR with some improvements and more operations, so I'll include it there.

Edit: Thanks for responding so quickly by the way!

Copy link
Owner

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Thanks!

@ascorbic ascorbic merged commit 405bbc4 into ascorbic:main Nov 10, 2025
16 checks passed
@mixie-bot mixie-bot bot mentioned this pull request Nov 10, 2025
@GeKorm GeKorm deleted the imgix-auto branch November 10, 2025 10:15
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