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

refactor: pass srcset modifiers through the options parameter #57

Merged
merged 2 commits into from
Nov 13, 2019

Conversation

sherwinski
Copy link
Contributor

This PR refactors how the new srcset modifier options (see #54, #55, and #56) are required to be passed to Imgix::Path#to_srcset. Instead of passing values directly through widths, width_tolerance, min_srcset, and/or max_srcset keyword parameters, users should now store any combination of these arguments in the new options parameter as a hash.
This change is being made to avoid confusion in naming between imgix URL parameters and parameters that modify object behavior. This should hopefully clarify through design of the interface which options modify how srcsets are generated versus how the image itself is modified through imgix's service.

Example:

client = Imgix::Client.new(host: 'testing.imgix.net', include_library_param: false).path('image.jpg')
client.to_srcset(options: {min_width: 500, max_width: 2000, width_tolerance: 0.20})

Will output the following:

https://testing.imgix.net/image.jpg?w=500&s=e39b3eddc94ae9f21c2d5ed5772c788e 500w,
https://testing.imgix.net/image.jpg?w=700&s=9c76f8c8fde1de38ddf85c2472ca6289 700w,
https://testing.imgix.net/image.jpg?w=980&s=2416cecd450f40f4a31b6af233d47d91 980w,
https://testing.imgix.net/image.jpg?w=1372&s=73ddbeace48bcb265ea1f24d2111e7e8 1372w,
https://testing.imgix.net/image.jpg?w=1920&s=0a3a9652aeae2262950c22cef2d97adf 1920w,
https://testing.imgix.net/image.jpg?w=2000&s=e51013d2c46f98c0f1b845a042d4caf2 2000w

@sherwinski sherwinski requested a review from jayeb November 8, 2019 23:39
@sherwinski sherwinski changed the title refactor: pass all srcset modifiers through the options parameter refactor: pass srcset modifiers through the options parameter Nov 13, 2019
@sherwinski sherwinski merged commit b8fce78 into master Nov 13, 2019
@sherwinski sherwinski deleted the refactor-srcset-options branch November 13, 2019 22:47
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