imgix-rails 3.0.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d6e78cf6981b5d33cefcdc0bfe59993e6b33ffe1
4
- data.tar.gz: edbfa9338682e38d1807c5cc79f53ab0a7f8db12
2
+ SHA256:
3
+ metadata.gz: ee4ca6aecc3acbcbb35b5c9b68731403e423f9b76421e14bbf270b727aa0c75d
4
+ data.tar.gz: 5397fee06ecb6b23d2e5fb0464736681b3d68976a87e5959b1b33f890a164acf
5
5
  SHA512:
6
- metadata.gz: d49c2e33a036cf41b01348494d1c7ff6b23946d61aa9886370aff95f387d2d6a9eca643ec24697cfc89664c87f5cc63e4a23e61cc9b21cf61daa42c3f6b53bd9
7
- data.tar.gz: b665088af2b88dca1b88d5fe5b59fd2f32ed256b3b17877254b0f16024588e9ce4fe301cb5c6c8d6d39458b14822e778236f0970abba02127a0650b971e68b16
6
+ metadata.gz: 54700c22ae9e911dd22139e4e03b45bff2c07b38ca8a23f6253a9311420424903babb1189db3a31bd0eaa70e88f8babeefe26cd95ce3d1691ab0804cdca782dc
7
+ data.tar.gz: df2ef3b2ba35d0f1296c6a161ff37ecbbe11a1dfda97c69b4c330b6049cdacf8129363db6b39394e6ce1146daed6f33049807763d4045753690ada32db276c98
@@ -0,0 +1,2 @@
1
+ # Default owners for repo
2
+ * @imgix/imgix-sdk-team
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
11
+
12
+ **Describe the bug**
13
+ A clear and concise description of what the bug is.
14
+
15
+ **To Reproduce**
16
+ Steps to reproduce the behavior:
17
+
18
+ **Expected behavior**
19
+ A clear and concise description of what you expected to happen.
20
+
21
+ **Screenshots**
22
+ If applicable, add screenshots to help explain your problem.
23
+
24
+ **Information:**
25
+ - imgix-rails version: [e.g. 4.0.0]
26
+
27
+ **Additional context**
28
+ Add any other context about the problem here.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
11
+
12
+ **Before you submit:**
13
+
14
+ - [ ] Please search through the [existing issues](https://github.com/imgix/imgix-rails/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if your feature has already been discussed.
15
+ - [ ] Please take a moment to find out whether your idea fits with the scope and aims of this project.
16
+
17
+ **Is your feature request related to a problem? Please describe.**
18
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
19
+
20
+ **Describe the solution you'd like**
21
+ A clear and concise description of what you want to happen.
22
+
23
+ **Describe alternatives you've considered**
24
+ A clear and concise description of any alternative solutions or features you've considered.
25
+
26
+ **Additional context**
27
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Question
3
+ about: Ask a question about the project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
11
+
12
+ **Before you submit:**
13
+
14
+ - [ ] Please search through the [existing issues](https://github.com/imgix/imgix-rails/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if your question has already been discussed.
15
+
16
+ **Question**
17
+ A clear and concise description of your question.
@@ -0,0 +1,73 @@
1
+ <!--
2
+ Hello, and thanks for contributing to imgix-rails! 🎉🙌
3
+ Please take a second to fill out PRs with the following template!
4
+ -->
5
+
6
+ # Description
7
+
8
+ <!-- What is accomplished by this PR? If there is something potentially controversial in your PR, please take a moment to tell us about your choices. -->
9
+
10
+ <!--
11
+ Please use the checklist that is most closely related to your PR, and delete the other checklists. -->
12
+
13
+ ## Checklist: Fixing typos/Doc change
14
+
15
+ - [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
16
+
17
+ ## Checklist: Bug Fix
18
+
19
+ - [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
20
+ - [ ] All existing unit tests are still passing (if applicable)
21
+ - [ ] Add new passing unit tests to cover the code introduced by your PR
22
+ - [ ] Update the readme
23
+ - [ ] Update or add any necessary API documentation
24
+ - [ ] Add some [steps](#steps-to-test) so we can test your bug fix
25
+
26
+ ## Checklist: New Feature
27
+
28
+ - [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
29
+ - [ ] Any breaking changes are specified on the commit on which they are introduced with `BREAKING CHANGE` in the body of the commit.
30
+ - [ ] If this is a big feature with breaking changes, consider [opening an issue](https://github.com/imgix/imgix-rails/issues/new?assignees=&labels=&template=feature_request.md&title=) to discuss first. This is completely up to you, but please keep in mind that your PR might not be accepted.
31
+ - [ ] Run unit tests to ensure all existing tests are still passing
32
+ - [ ] Add new passing unit tests to cover the code introduced by your PR
33
+ - [ ] Update the readme
34
+ - [ ] Add some [steps](#steps-to-test) so we can test your cool new feature!
35
+
36
+ ## Steps to Test
37
+
38
+ <!-- Delete this selction if you are just submitting a doc change/small fix -->
39
+
40
+ <!-- A code example or a set of steps is preferred -->
41
+
42
+ Related issue: [e.g. #42]
43
+
44
+ Code:
45
+
46
+ ```rb
47
+ # A standalone example of what the PR solves
48
+ ```
49
+
50
+ <!-- A link to a codepen/codesandbox is also an option. -->
51
+
52
+ <!--
53
+
54
+ ## Conventional Commit Spec
55
+
56
+ PR titles should be in the format `<type>(<scope>): <description>`. For example: `chore(readme): fix typo`
57
+
58
+ `type` can be any of the follow:
59
+ - `feat`: a feature, or breaking change
60
+ - `fix`: a bug-fix
61
+ - `test`: Adding missing tests or correcting existing tests
62
+ - `docs`: documentation only changes (readme, changelog, contributing guide)
63
+ - `refactor`: a code change that neither fixes a bug nor adds a feature
64
+ - `chore`: reoccurring tasks for project maintainability (example scopes: release, deps)
65
+ - `config`: changes to tooling configurations used in the project
66
+ - `build`: changes that affect the build system or external dependencies (example scopes: npm, bundler, gradle)
67
+ - `ci`: changes to CI configuration files and scripts (example scopes: travis)
68
+ - `perf`: a code change that improves performance
69
+ - `style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
70
+
71
+ `scope` is optional, and can be anything.
72
+ `description` should be a short description of the change, written in the imperative-mood.
73
+ -->
@@ -1,8 +1,6 @@
1
1
  language: ruby
2
- before_install:
3
- - rvm get head
4
2
  rvm:
5
3
  - 2.3.1
6
4
  - 2.2.5
7
- - jruby-9.0.5.0
5
+ - jruby
8
6
  script: bundle exec rspec
@@ -0,0 +1,52 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [4.1.0](https://github.com/imgix/imgix-rb/compare/4.0.2...4.1.0) - October 13, 2020
7
+
8
+ ### Release Notes
9
+ Version 4.1.0 has been released! The goal of this release is to offer flexibility to those using imgix-rb's purger capabilities through imgix-rails.
10
+
11
+ Prior to this release, this gem offered purging capability through `imgix '~> 3.0'`. However, that purging capability has been deprecated in favor of the new-style purging API––available now in [imgix-rb v4.0.0](https://github.com/imgix/imgix-rb/releases/tag/4.0.0).
12
+
13
+ To upgrade to the new purging API used in `imgix '~> 4.0'`:
14
+
15
+ - navigate to the [API Keys](https://dashboard.imgix.com/api-keys) portion of your dashboard
16
+ - generate a new API Key
17
+ - use this new key in your imgix client: `Imgix::Client.new(domain: '...', api_key: NEW_API_KEY)`
18
+
19
+ ### Changes
20
+ - build: use optimistic constraint for imgix >= 3.0 ([#104](https://github.com/imgix/imgix-rails/pull/104))
21
+
22
+ ## [4.0.2](https://github.com/imgix/imgix-rb/compare/4.0.1...4.0.2) - July 31, 2020
23
+ - fix: replace `opts[:host`] with `opts[:domain]` to resolve deprecation warnings ([#96](https://github.com/imgix/imgix-rails/pull/96))
24
+
25
+ ## [4.0.1](https://github.com/imgix/imgix-rb/compare/4.0.0...4.0.1) - June 10, 2020
26
+
27
+ - fix: update rake version ([#94](https://github.com/imgix/imgix-rails/pull/94))
28
+
29
+ ## [4.0.0](https://github.com/imgix/imgix-rb/compare/3.1.0...4.0.0) - December 03, 2019
30
+
31
+ The v4.0.0 release of imgix-rails introduces a variety of improvements relating to how this gem handles and generates `srcset` attributes. However, in releasing this version there are some significant interface/behavioral changes that users need to be aware of. Users should note that the `min_width` and `max_width` fields (passed via `tag_options`), as well as the `widths` field, have all been moved to their own encompassing `srcset_options` field. This is done with the intention of providing a more organized and intuitive experience when fine-tuning how `srcset` width pairs are generated. See the following example demonstrating this new pattern:
32
+
33
+ ```erb
34
+ <%= ix_image_tag('/unsplash/hotairballoon.jpg',
35
+ srcset_options: { min_width: 1000, max_width: 2500},
36
+ tag_options: { alt: 'A hot air balloon on a sunny day' }) %>
37
+ ```
38
+
39
+ For users migrating to version 4.0 or later, it is important that all srcset-related modifiers be passed via `srcset_options`, as doing so through `tag_options` or `widths` directly will result in errors. For more details on these modifiers, please see the [ix_image_tag](https://github.com/imgix/imgix-rails#ix_image_tag) or [ix_picture_tag](https://github.com/imgix/imgix-rails#ix_picture_tag) sections.
40
+
41
+ In addition to these changes, imgix-rails is now capable of producing [fixed-image srcsets](https://github.com/imgix/imgix-rb#fixed-image-rendering). Users should note that when certain dimension information is provided, imgix-rails will produce a `srcset` at different screen resolutions rather than the typical width pairs. This feature provides expanded functionality to cover more `srcset` use cases that users can take advantage of. We are always happy to provide our users with more tools to assist them in their efforts to build out responsive images on the web.
42
+
43
+ * feat: utilize Imgix::Path#to_srcset when constructing srcsets ([#83](https://github.com/imgix/imgix-rails/pull/83))
44
+ * chore: remove deprecated domain sharding behavior ([#80](https://github.com/imgix/imgix-rails/pull/80))
45
+ * fix: deprecate resizing height when maintaining aspect ratio ([#78](https://github.com/imgix/imgix-rails/pull/78))
46
+
47
+ ## [3.1.0](https://github.com/imgix/imgix-rb/compare/3.0.2...3.1.0) - October 25, 2019
48
+
49
+ * Update bundler dev dependency to include new major version 2.x ([#71](https://github.com/imgix/imgix-rb/pull/71))
50
+ * README: Fix typo ([#73](https://github.com/imgix/imgix-rb/pull/73))
51
+ * docs: add ActiveStorage instructions to README ([#74](https://github.com/imgix/imgix-rb/pull/74))
52
+ * chore(deprecate): emit warning when generating srcsets ([ccc906b](https://github.com/imgix/imgix-rails/commit/ccc906be749945f6f843b5eeb04ab03a292ccbfb)) ([e2ffc2b](https://github.com/imgix/imgix-rails/commit/e2ffc2b4f847c15ea73fa161b673885e704e4cf2))
data/README.md CHANGED
@@ -1,52 +1,60 @@
1
- [![imgix logo](https://assets.imgix.net/imgix-logo-web-2014.pdf?page=2&fm=png&w=200&h=200)](https://imgix.com)
1
+ <!-- ix-docs-ignore -->
2
+ ![imgix logo](https://assets.imgix.net/sdk-imgix-logo.svg)
3
+
4
+ `imgix-rails` is a gem for integrating [imgix](https://www.imgix.com/) into Ruby on Rails applications. It builds on [imgix-rb](https://github.com/imgix/imgix-rb) to offer a few Rails-specific interfaces.
5
+
6
+ [![Gem Version](https://img.shields.io/gem/v/imgix-rails.svg)](https://rubygems.org/gems/imgix-rails)
7
+ [![Build Status](https://travis-ci.org/imgix/imgix-rails.svg?branch=main)](https://travis-ci.org/imgix/imgix-rails)
8
+ ![Downloads](https://img.shields.io/gem/dt/imgix-rails)
9
+ [![License](https://img.shields.io/github/license/imgix/imgix-rails)](https://github.com/imgix/imgix-rails/blob/main/LICENSE)
10
+
11
+ ---
12
+ <!-- /ix-docs-ignore -->
13
+
14
+ - [Installation](#installation)
15
+ - [Usage](#usage)
16
+ - [Configuration](#configuration)
17
+ - [Multi-source configuration](#multi-source-configuration)
18
+ - [`ix_image_tag`](#iximagetag)
19
+ - [Fixed image rendering](#fixed-image-rendering)
20
+ - [`ix_picture_tag`](#ixpicturetag)
21
+ - [`ix_image_url`](#iximageurl)
22
+ - [Usage in Sprockets](#usage-in-sprockets)
23
+ - [Using With Image Uploading Libraries](#using-with-image-uploading-libraries)
24
+ - [Paperclip and CarrierWave](#paperclip-and-carrierwave)
25
+ - [Refile](#refile)
26
+ - [Active Storage](#active-storage)
27
+ - [S3](#s3)
28
+ - [GCS](#gcs)
29
+ - [Upgrade Guides](#upgrade-guides)
30
+ - [3.x to 4.0](#3x-to-40)
31
+ - [Development](#development)
32
+ - [Contributing](#contributing)
33
+ - [Code of Conduct](#code-of-conduct)
2
34
 
3
- # imgix-rails [![Build Status](https://travis-ci.org/imgix/imgix-rails.svg?branch=master)](https://travis-ci.org/imgix/imgix-rails)
4
-
5
- `imgix-rails` is a gem designed to make integrating imgix into your Rails app easier. It builds on [imgix-rb](https://github.com/imgix/imgix-rb) to offer a few Rails-specific interfaces.
6
-
7
- imgix is a real-time image processing service and CDN. It allows you to manipulate images merely by changing their URL parameters. For a full list of URL parameters, please see the [imgix URL API documentation](https://www.imgix.com/docs/reference).
8
-
9
- We recommend using something like [Paperclip](https://github.com/thoughtbot/paperclip), [Refile](https://github.com/refile/refile), [Carrierwave](https://github.com/carrierwaveuploader/carrierwave), or [s3_direct_upload](https://github.com/waynehoover/s3_direct_upload) to handle uploads. After they've been uploaded, you can then serve them using this gem.
10
-
11
- * [Installation](#installation)
12
- * [Usage](#usage)
13
- * [Configuration](#configuration)
14
- * [ix_image_tag](#ix_image_tag)
15
- * [ix_picture_tag](#ix_picture_tag)
16
- * [ix_image_url](#ix_image_url)
17
- * [Usage in Sprockets](#usage-in-sprockets)
18
- * [Using With Image Uploading Libraries](#using-with-image-uploading-libraries)
19
- * [Paperclip and CarrierWave](#paperclip-and-carrierwave)
20
- * [Refile](#refile)
21
- * [Development](#development)
22
- * [Contributing](#contributing)
23
-
24
-
25
- <a name="installation"></a>
26
35
  ## Installation
27
36
 
28
37
  Add this line to your application's Gemfile:
29
38
 
30
- ```ruby
39
+ ```rb
31
40
  gem 'imgix-rails'
32
41
  ```
33
42
 
34
43
  And then execute:
35
44
 
36
- $ bundle
37
-
45
+ ```bash
46
+ $ bundle
47
+ ```
38
48
 
39
- <a name="usage"></a>
40
49
  ## Usage
41
50
 
42
51
  imgix-rails provides a few different hooks to work with your existing Rails application. All current methods are drop-in replacements for the `image_tag` helper.
43
52
 
44
- <a name="configuration"></a>
45
53
  ### Configuration
46
54
 
47
55
  Before you get started, you will need to define your imgix configuration in your `config/application.rb`, or in an environment-specific configuration file.
48
56
 
49
- ```ruby
57
+ ```rb
50
58
  Rails.application.configure do
51
59
  config.imgix = {
52
60
  source: "assets.imgix.net"
@@ -56,22 +64,22 @@ end
56
64
 
57
65
  The following configuration flags will be respected:
58
66
 
59
- - `:use_https` toggles the use of HTTPS. Defaults to `true`
60
- - `:source` a String or Array that specifies the imgix Source address. Should be in the form of `"assets.imgix.net"`.
61
- - `:srcset_width_tolerance` an optional numeric value determining the maximum tolerance allowable, between the downloaded dimensions and rendered dimensions of the image (default `.08` i.e. `8%`).
62
- - `:secure_url_token` an optional secure URL token found in your dashboard (https://dashboard.imgix.com) used for signing requests
63
- - `:shard_strategy` Specify [domain sharding strategy](https://github.com/imgix/imgix-rb#domain-sharded-urls) with multiple sources. Acceptable values are `:cycle` and `:crc`. `:crc` is used by default.
67
+ - `use_https`: toggles the use of HTTPS. Defaults to `true`
68
+ - `source`: a String or Array that specifies the imgix Source address. Should be in the form of `"assets.imgix.net"`.
69
+ - `srcset_width_tolerance`: an optional numeric value determining the maximum tolerance allowable, between the downloaded dimensions and rendered dimensions of the image (default `0.08` i.e. `8%`).
70
+ - `secure_url_token`: an optional secure URL token found in your dashboard (https://dashboard.imgix.com) used for signing requests
71
+ - `include_library_param`: toggles the inclusion of the [`ixlib` parameter](https://github.com/imgix/imgix-rb#what-is-the-ixlib-param-on-every-request). Defaults to `true`.
64
72
 
65
73
  #### Multi-source configuration
66
74
 
67
75
  In addition to the standard configuration flags, the following options can be used for multi-source support.
68
76
 
69
- - `:sources` a Hash of imgix source-secure_url_token key-value pairs. If the value for a source is `nil`, URLs generated for the corresponding source won't be secured. `:sources` and `:source` *cannot* be used together.
70
- - `:default_source` optionally specify a default source for generating URLs.
77
+ - `sources`: a Hash of imgix source-secure_url_token key-value pairs. If the value for a source is `nil`, URLs generated for the corresponding source won't be secured. `sources` and `source` *cannot* be used together.
78
+ - `default_source`: optionally specify a default source for generating URLs.
71
79
 
72
80
  Example:
73
81
 
74
- ```ruby
82
+ ```rb
75
83
  Rails.application.configure do
76
84
  config.imgix = {
77
85
  sources: {
@@ -83,19 +91,23 @@ Rails.application.configure do
83
91
  end
84
92
  ```
85
93
 
86
- <a name="ix_image_tag"></a>
87
- ### ix_image_tag
94
+ ### `ix_image_tag`
88
95
 
89
- The `ix_image_tag` helper method makes it easy to pass parameters to imgix to handle resizing, cropping, etc. It also simplifies adding responsive imagery to your Rails app by automatically generating a `srcset` based on the parameters you pass. We talk a bit about using the `srcset` attribute in an application in the following blog post: [“Responsive Images with `srcset` and imgix.”](https://blog.imgix.com/2015/08/18/responsive-images-with-srcset-imgix.html).
96
+ The `ix_image_tag` helper method makes it easy to pass parameters to imgix to handle resizing, cropping, etc. It also simplifies adding responsive imagery to your Rails app by automatically generating a `srcset` based on the parameters you pass. We talk a bit about using the `srcset` attribute in an application in the following blog post: [“Responsive Images with `srcset` and imgix.”](https://docs.imgix.com/tutorials/responsive-images-srcset-imgix?_ga=utm_medium=referral&utm_source=sdk&utm_campaign=rails-readme).
90
97
 
91
- `ix_image_tag` generates `<img>` tags with a filled-out `srcset` attribute that leans on imgix to do the hard work. If you already know the minimum or maximum number of physical pixels that this image will need to be displayed at, you can pass the `min_width` and/or `max_width` options. This will result in a smaller, more tailored `srcset`.
98
+ `ix_image_tag` generates `<img>` tags with a filled-out `srcset` attribute that leans on [imgix-rb](https://github.com/imgix/imgix-rb) to do the hard work. It also makes a variety of options available for customizing how the `srcset` is generated. For example, if you already know the minimum or maximum number of physical pixels that this image will need to be displayed at, you can pass the `min_width` and/or `max_width` options. This will result in a smaller, more tailored `srcset`.
92
99
 
93
100
  `ix_image_tag` takes the following arguments:
94
101
 
95
- * `source`: an optional String indicating the source to be used. If unspecified `:source` or `:default_source` will be used. If specified, the value must be defined in the config.
102
+ * `source`: An optional String indicating the source to be used. If unspecified `:source` or `:default_source` will be used. If specified, the value must be defined in the config.
96
103
  * `path`: The path or URL of the image to display.
97
- * `tag_options`: Any options to apply to the generated `img` element. This is useful for adding class names, etc.
104
+ * `tag_options`: HTML attributes to apply to the generated `img` element. This is useful for adding class names, alt tags, etc.
98
105
  * `url_params`: The imgix URL parameters to apply to this image. These will be applied to each URL in the `srcset` attribute, as well as the fallback `src` attribute.
106
+ * `srcset_options`: A variety of options that allow for fine tuning `srcset` generation. More information on each of these modifiers can be found in the [imgix-rb documentation](https://github.com/imgix/imgix-rb#srcset-generation). Any of the following can be passed as arguments:
107
+ * [`widths`](https://github.com/imgix/imgix-rb#custom-widths): An array of exact widths that `srcset` pairs will be generated with.
108
+ * [`min_width`](https://github.com/imgix/imgix-rb#minimum-and-maximum-width-ranges): The minimum width that `srcset` pairs will be generated with. Will be ignored if `widths` are provided.
109
+ * [`max_width`](https://github.com/imgix/imgix-rb#minimum-and-maximum-width-ranges): The maximum width that `srcset` pairs will be generated with. Will be ignored if `widths` are provided.
110
+ * [`disable_variable_quality`](https://github.com/imgix/imgix-rb#variable-qualities): Pass `true` to disable variable quality parameters when generating a `srcset` ([fixed-images only](https://github.com/imgix/imgix-rails#fixed-image-rendering)). In addition, imgix-rails will respect an overriding `q` (quality) parameter if one is provided through `url_params`.
99
111
 
100
112
  ```erb
101
113
  <%= ix_image_tag('/unsplash/hotairballoon.jpg', url_params: { w: 300, h: 500, fit: 'crop', crop: 'right'}, tag_options: { alt: 'A hot air balloon on a sunny day' }) %>
@@ -127,7 +139,7 @@ Will generate URLs using `assets2.imgix.net` source.
127
139
 
128
140
  We recommend leveraging this to generate powerful helpers within your application like the following:
129
141
 
130
- ```ruby
142
+ ```rb
131
143
  def profile_image_tag(user)
132
144
  ix_image_tag(user.profile_image_url, url_params: { w: 100, h: 200, fit: 'crop' })
133
145
  end
@@ -142,12 +154,30 @@ Then rendering the portrait in your application is very easy:
142
154
  If you already know all the exact widths you need images for, you can specify that by passing the `widths` option as an array. In this case, imgix-rails will only generate `srcset` pairs for the specified `widths`.
143
155
 
144
156
  ```erb
145
- <%= ix_image_tag('/unsplash/hotairballoon.jpg', widths: [320, 640, 960, 1280], url_params: { w: 300, h: 500, fit: 'crop', crop: 'right'}, tag_options: { alt: 'A hot air balloon on a sunny day' }) %>
157
+ <%= ix_image_tag('/unsplash/hotairballoon.jpg', srcset_options: { widths: [320, 640, 960, 1280] }, tag_options: { alt: 'A hot air balloon on a sunny day' }) %>
146
158
  ```
147
159
 
160
+ #### Fixed image rendering
148
161
 
149
- <a name="ix_picture_tag"></a>
150
- ### ix_picture_tag
162
+ In cases where enough information is provided about an image's dimensions, `ix_image_tag` will instead build a `srcset` that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are `w`, `h`, and `ar`. By invoking `ix_image_tag` with either a width or the height and aspect ratio (along with `fit=crop`, typically) provided, a different srcset will be generated for a fixed-size image instead.
163
+
164
+ ```erb
165
+ <%= ix_image_tag('/unsplash/hotairballoon.jpg', url_params: {w: 1000}) %>
166
+ ```
167
+
168
+ Will render the following HTML:
169
+
170
+ ```html
171
+ <img srcset="https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=1&amp;q=75 1x,
172
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=2&amp;q=50 2x,
173
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=3&amp;q=35 3x,
174
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=4&amp;q=23 4x,
175
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=5&amp;q=20 5x" sizes="100vw" src="https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000">
176
+ ```
177
+
178
+ Fixed image rendering will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a `srcset`. This technique is commonly used to compensate for the increased filesize of high-DPR images. Since high-DPR images are displayed at a higher pixel density on devices, image quality can be lowered to reduce overall filesize without sacrificing perceived visual quality. For more information and examples of this technique in action, see [this blog post](https://blog.imgix.com/2016/03/30/dpr-quality?_ga=utm_medium=referral&utm_source=sdk&utm_campaign=rails-readme). This behavior will respect any overriding `q` value passed in via `url_params` and can be disabled altogether with `srcset_options: { disable_variable_quality: true }`.
179
+
180
+ ### `ix_picture_tag`
151
181
 
152
182
  The `ix_picture_tag` helper method makes it easy to generate `picture` elements in your Rails app. `picture` elements are useful when an images needs to be art directed differently at different screen sizes.
153
183
 
@@ -158,6 +188,11 @@ The `ix_picture_tag` helper method makes it easy to generate `picture` elements
158
188
  * `tag_options`: Any options to apply to the parent `picture` element. This is useful for adding class names, etc.
159
189
  * `url_params`: Default imgix options. These will be used to generate a fallback `img` tag for older browsers, and used in each `source` unless overridden by `breakpoints`.
160
190
  * `breakpoints`: A hash describing the variants. Each key must be a media query (e.g. `(max-width: 880px)`), and each value must be a hash of parameter overrides for that media query. A `source` element will be generated for each breakpoint specified.
191
+ * `srcset_options`: A variety of options that allow for fine tuning `srcset` generation. More information on each of these modifiers can be found in the [imgix-rb documentation](https://github.com/imgix/imgix-rb#srcset-generation). Any of the following can be passed as arguments:
192
+ * [`widths`](https://github.com/imgix/imgix-rb#custom-widths): An array of exact widths that `srcset` pairs will be generated with.
193
+ * [`min_width`](https://github.com/imgix/imgix-rb#minimum-and-maximum-width-ranges): The minimum width that `srcset` pairs will be generated with. Will be ignored if `widths` are provided.
194
+ * [`max_width`](https://github.com/imgix/imgix-rb#minimum-and-maximum-width-ranges): The maximum width that `srcset` pairs will be generated with. Will be ignored if `widths` are provided.
195
+ * [`disable_variable_quality`](https://github.com/imgix/imgix-rb#variable-qualities): Pass `true` to disable variable quality parameters when generating a `srcset` ([fixed-images only](https://github.com/imgix/imgix-rails#fixed-image-rendering)). In addition, imgix-rails will respect an overriding `q` (quality) parameter if one is provided through `url_params`.
161
196
 
162
197
  ```erb
163
198
  <%= ix_picture_tag('bertandernie.jpg',
@@ -213,8 +248,7 @@ To generate a `picture` element on a different source:
213
248
  ) %>
214
249
  ```
215
250
 
216
- <a name="ix_image_url"></a>
217
- ### ix_image_url
251
+ ### `ix_image_url`
218
252
 
219
253
  The `ix_image_url` helper makes it easy to generate a URL to an image in your Rails app.
220
254
 
@@ -238,17 +272,16 @@ https://assets2.imgix.net/users/1/avatar.png?w=400&h=300
238
272
 
239
273
  Since `ix_image_url` lives inside `UrlHelper`, it can also be used in places other than your views quite easily. This is useful for things such as including imgix URLs in JSON output from a serializer class.
240
274
 
241
- ```ruby
275
+ ```rb
242
276
  include Imgix::Rails::UrlHelper
243
277
 
244
278
  puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
245
279
  # => https://assets.imgix.net/users/1/avatar.png?w=400&h=300
246
280
  ```
247
281
 
248
- <a name="usage-in-sprockets"></a>
249
282
  #### Usage in Sprockets
250
283
 
251
- `ix_image_url` is also pulled in as a Sprockets helper, so you can generate imgix URLs in your asset pipline files. For example, here's how it would work inside an `.scss.erb` file:
284
+ `ix_image_url` is also pulled in as a Sprockets helper, so you can generate imgix URLs in your asset pipeline files. For example, here's how it would work inside an `.scss.erb` file:
252
285
 
253
286
  ```scss
254
287
  .something {
@@ -256,13 +289,10 @@ puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
256
289
  }
257
290
  ```
258
291
 
259
- <a name="using-with-image-uploading-libraries"></a>
260
292
  ## Using With Image Uploading Libraries
261
293
 
262
294
  imgix-rails plays well with image uploading libraries, because it just requires a URL and optional parameters as arguments. A good way to handle this interaction is by creating helpers that bridge between your uploading library of choice and imgix-rails. Below are examples of how this can work with some common libraries. Please submit an issue if you'd like to see specific examples for another!
263
295
 
264
-
265
- <a name="paperclip-and-carrierwave"></a>
266
296
  ### Paperclip and CarrierWave
267
297
 
268
298
  Paperclip and CarrierWave can directly provide paths to uploaded images, so we can use them with imgix-rails without a bridge.
@@ -271,8 +301,6 @@ Paperclip and CarrierWave can directly provide paths to uploaded images, so we c
271
301
  <%= ix_image_tag(@user.avatar.path, { auto: 'format', fit: 'crop', w: 500}) %>
272
302
  ```
273
303
 
274
-
275
- <a name="refile"></a>
276
304
  ### Refile
277
305
 
278
306
  Since Refile doesn't actually store URLs or paths in the database (instead using a "prefix" + image identifier), the basic setup is slightly different. In this case, we use a couple helpers that bridge between Refile and imgix-rails.
@@ -303,16 +331,88 @@ end
303
331
  <%= ix_refile_image_tag(@blog_post, :hero_photo, {auto: 'format', fit: 'crop', w: 500}) %>
304
332
  ```
305
333
 
334
+ ### Active Storage
335
+
336
+ To set up imgix with ActiveStorage, first ensure that the remote source your ActiveStorage service is pointing to is the same as your imgix source — such as an s3 bucket.
337
+
338
+ ### S3
339
+ **config/storage.yml**
340
+
341
+ ```yml
342
+ service: S3
343
+ access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
344
+ secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
345
+ region: us-east-1
346
+ bucket: your_own_bucket
347
+ ```
348
+
349
+ ### GCS
350
+ ```yml
351
+ google:
352
+ service: GCS
353
+ project: Project Name
354
+ credentials: <%= Rails.root.join("path/to/key.json") %>
355
+ bucket: Bucket Name
356
+ ```
357
+
358
+ Modify your `active_storage.service` setting depending on what environment you are using. For example, to use Amazon s3 in production, make the following change:
359
+
360
+ **config/environments/production.rb**
361
+
362
+ ```rb
363
+ config.active_storage.service = :amazon
364
+ ```
365
+
366
+ To use Google GCS in production, configure the active storage service like so:
367
+
368
+ ```rb
369
+ config.active_storage.service = :google
370
+ ```
371
+
372
+ As you would normally with imgix-rails, configure your application to point to your imgix source:
373
+
374
+ **config/application.rb**
375
+
376
+ ```rb
377
+ Rails.application.configure do
378
+ config.imgix = {
379
+ source: your_domain,
380
+ use_https: true,
381
+ include_library_param: true
382
+ }
383
+ end
384
+ ```
385
+
386
+ Finally, the two can be used together by passing in the filename of the ActiveStorage blob into the imgix-rails helper function:
387
+
388
+ **show.html.erb**
389
+
390
+ ```erb
391
+ <%= ix_image_tag(@your_model.image.key) %>
392
+ ```
393
+
394
+ ## Upgrade Guides
395
+
396
+ ### 3.x to 4.0
397
+
398
+ The v4.0.0 release of imgix-rails introduces a variety of improvements relating to how this gem handles and generates `srcset` attributes. However, in releasing this version there are some significant interface/behavioral changes that users need to be aware of. Users should note that the `min_width` and `max_width` fields (passed via `tag_options`), as well as the `widths` field, have all been moved to their own encompassing `srcset_options` field. This is done with the intention of providing a more organized and intuitive experience when fine-tuning how `srcset` width pairs are generated. See the following example demonstrating this new pattern:
399
+
400
+ ```erb
401
+ <%= ix_image_tag('/unsplash/hotairballoon.jpg',
402
+ srcset_options: { min_width: 1000, max_width: 2500},
403
+ tag_options: { alt: 'A hot air balloon on a sunny day' }) %>
404
+ ```
405
+
406
+ For users migrating to version 4.0 or later, it is important that all srcset-related modifiers be passed via `srcset_options`, as doing so through `tag_options` or `widths` directly will result in errors. For more details on these modifiers, please see the [ix_image_tag](https://github.com/imgix/imgix-rails#ix_image_tag) or [ix_picture_tag](https://github.com/imgix/imgix-rails#ix_picture_tag) sections.
407
+
408
+ In addition to these changes, imgix-rails is now capable of producing [fixed-image srcsets](https://github.com/imgix/imgix-rb#fixed-image-rendering). Users should note that when certain dimension information is provided, imgix-rails will produce a `srcset` at different screen resolutions rather than the typical width pairs. This feature provides expanded functionality to cover more `srcset` use cases that users can take advantage of. We are always happy to provide our users with more tools to assist them in their efforts to build out responsive images on the web.
306
409
 
307
- <a name="development"></a>
308
410
  ## Development
309
411
 
310
412
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
311
413
 
312
414
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
313
415
 
314
-
315
- <a name="contributing"></a>
316
416
  ## Contributing
317
417
 
318
418
  1. Fork it ( https://github.com/[my-github-username]/imgix-rails/fork )
@@ -14,6 +14,12 @@ Gem::Specification.new do |spec|
14
14
  spec.description = %q{Makes integrating imgix into your Rails app easier. It builds on imgix-rb to offer a few Rails-specific interfaces. Please see https://github.com/imgix/imgix-rails for more details.}
15
15
  spec.homepage = "https://github.com/imgix/imgix-rails"
16
16
 
17
+ spec.metadata = {
18
+ 'bug_tracker_uri' => 'https://github.com/imgix/imgix-rails/issues',
19
+ 'changelog_uri' => 'https://github.com/imgix/imgix-rails/blob/main/CHANGELOG.md',
20
+ 'documentation_uri' => "https://www.rubydoc.info/gems/imgix-rails/#{spec.version}",
21
+ 'source_code_uri' => "https://github.com/imgix/imgix-rails/tree/v#{spec.version}"
22
+ }
17
23
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
24
  # delete this section to allow pushing this gem to any host.
19
25
  if spec.respond_to?(:metadata)
@@ -27,10 +33,10 @@ Gem::Specification.new do |spec|
27
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
34
  spec.require_paths = ["lib"]
29
35
 
30
- spec.add_runtime_dependency "imgix", "~> 1.1", ">= 1.1.0"
36
+ spec.add_runtime_dependency "imgix", ">= 3.0"
31
37
 
32
- spec.add_development_dependency "bundler", "~> 1.9"
33
- spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "bundler", ">=1.9"
39
+ spec.add_development_dependency "rake", "~> 12.3"
34
40
  spec.add_development_dependency "rspec"
35
41
  spec.add_development_dependency "rspec-rails"
36
42
  end
@@ -8,7 +8,6 @@ require "active_support"
8
8
 
9
9
  module Imgix
10
10
  module Rails
11
- STRATEGIES = [:crc, :cycle]
12
11
  class Config < ::ActiveSupport::OrderedOptions; end
13
12
 
14
13
  def self.config
@@ -1,35 +1,42 @@
1
1
  require "imgix/rails/tag"
2
2
  require "imgix/rails/image_tag"
3
+ require "action_view"
3
4
 
4
5
  class Imgix::Rails::PictureTag < Imgix::Rails::Tag
5
6
  include ActionView::Context
6
7
 
7
- def initialize(path, source: nil, tag_options: {}, url_params: {}, breakpoints: {}, widths: [])
8
+ def initialize(path, source: nil, tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
8
9
  @path = path
9
10
  @source = source
10
11
  @tag_options = tag_options
11
12
  @url_params = url_params
12
13
  @breakpoints = breakpoints
13
- @widths = widths.length > 0 ? widths : target_widths
14
+ @srcset_options = srcset_options
14
15
  end
15
16
 
16
17
  def render
17
18
  content_tag(:picture, @tag_options) do
18
19
  @breakpoints.each do |media, opts|
20
+ validate_opts(opts)
21
+
19
22
  source_tag_opts = opts[:tag_options] || {}
20
23
  source_tag_url_params = opts[:url_params] || {}
21
- widths = opts[:widths]
22
- unsupported_opts = opts.except(:tag_options, :url_params, :widths)
23
- if unsupported_opts.length > 0
24
- raise "'#{unsupported_opts.keys.join("', '")}' key(s) not supported; use tag_options, url_params, widths."
25
- end
26
-
24
+ srcset_options = opts[:srcset_options] || {}
27
25
  source_tag_opts[:media] ||= media
28
- source_tag_opts[:srcset] ||= srcset(url_params: @url_params.clone.merge(source_tag_url_params), widths: widths)
26
+ source_tag_opts[:srcset] ||= srcset(url_params: @url_params.clone.merge(source_tag_url_params), srcset_options: srcset_options)
27
+
29
28
  concat(content_tag(:source, nil, source_tag_opts))
30
29
  end
31
30
 
32
- concat Imgix::Rails::ImageTag.new(@path, source: @source, url_params: @url_params).render
31
+ concat Imgix::Rails::ImageTag.new(@path, source: @source, url_params: @url_params, srcset_options: @srcset_options).render
33
32
  end
34
33
  end
34
+
35
+ private
36
+ def validate_opts(opts = {})
37
+ unsupported_opts = opts.except(:tag_options, :url_params, :srcset_options)
38
+ if unsupported_opts.length > 0
39
+ raise "'#{unsupported_opts.keys.join("', '")}' key(s) not supported; use tag_options, url_params, srcset_options."
40
+ end
41
+ end
35
42
  end
@@ -1,79 +1,30 @@
1
1
  require "imgix/rails/url_helper"
2
+ require "action_view"
2
3
 
3
4
  class Imgix::Rails::Tag
4
5
  include Imgix::Rails::UrlHelper
5
6
  include ActionView::Helpers
6
7
 
7
- def initialize(path, source: nil, tag_options: {}, url_params: {}, widths: [])
8
+ def initialize(path, source: nil, tag_options: {}, url_params: {}, srcset_options: {})
8
9
  @path = path
9
10
  @source = source
10
11
  @tag_options = tag_options
11
12
  @url_params = url_params
12
- @widths = widths.length > 0 ? widths : target_widths
13
+ @srcset_options = srcset_options
13
14
  end
14
15
 
15
16
  protected
16
17
 
17
- def srcset(url_params: @url_params, widths: @widths)
18
- widths = widths || target_widths
18
+ def srcset(source: @source, path: @path, url_params: @url_params, srcset_options: @srcset_options, tag_options: @tag_options)
19
+ params = url_params.clone
19
20
 
20
- srcset_url_params = url_params.clone
21
- srcsetvalue = widths.map do |width|
22
- srcset_url_params[:w] = width
21
+ width_tolerance = ::Imgix::Rails.config.imgix[:srcset_width_tolerance]
22
+ min_width = @srcset_options[:min_width]
23
+ max_width = @srcset_options[:max_width]
24
+ widths = @srcset_options[:widths]
25
+ disable_variable_quality = @srcset_options[:disable_variable_quality]
26
+ options = { widths: widths, width_tolerance: width_tolerance, min_width: min_width, max_width: max_width, disable_variable_quality: disable_variable_quality}
23
27
 
24
- if url_params[:w].present? && url_params[:h].present?
25
- srcset_url_params[:h] = (width * (url_params[:h].to_f / url_params[:w])).round
26
- end
27
-
28
- "#{ix_image_url(@source, @path, srcset_url_params)} #{width}w"
29
- end.join(', ')
30
- end
31
-
32
- @@standard_widths = nil
33
-
34
- def compute_standard_widths
35
- tolerance = ::Imgix::Rails.config.imgix[:srcset_width_tolerance] || SRCSET_TOLERANCE
36
- prev = MINIMUM_SCREEN_WIDTH
37
- widths = []
38
- while prev <= MAXIMUM_SCREEN_WIDTH do
39
- widths.append(2 * (prev/2).round) # Ensure widths are even
40
- prev = prev * (1 + tolerance*2.0)
41
- end
42
-
43
- widths
28
+ ix_image_srcset(@source, @path, params, options)
44
29
  end
45
-
46
- def standard_widths
47
- return @@standard_widths if @@standard_widths
48
-
49
- @@standard_widths = compute_standard_widths
50
- @@standard_widths.freeze
51
-
52
- @@standard_widths
53
- end
54
-
55
- private
56
-
57
- MINIMUM_SCREEN_WIDTH = 100
58
- MAXIMUM_SCREEN_WIDTH = 8192 # Maximum width supported by imgix
59
- SRCSET_TOLERANCE = 0.08
60
-
61
- # Return the widths to generate given the input `sizes`
62
- # attribute.
63
- #
64
- # @return {Array} An array of {Fixnum} instances representing the unique `srcset` URLs to generate.
65
- def target_widths
66
- min_width = @tag_options[:min_width]
67
- max_width = @tag_options[:max_width]
68
- if min_width || max_width
69
- min_width = min_width || MINIMUM_SCREEN_WIDTH
70
- max_width = max_width || MAXIMUM_SCREEN_WIDTH
71
- widths = standard_widths.select { |w| min_width <= w && w <= max_width }
72
- else
73
- widths = standard_widths
74
- end
75
-
76
- widths
77
- end
78
-
79
30
  end
@@ -10,28 +10,65 @@ module Imgix
10
10
  when 1
11
11
  path = args[0]
12
12
  source = nil
13
- options = {}
13
+ params = {}
14
14
  when 2
15
15
  if args[0].is_a?(String) && args[1].is_a?(Hash)
16
16
  source = nil
17
17
  path = args[0]
18
- options = args[1]
18
+ params = args[1]
19
19
  elsif args[0].is_a?(String) && args[1].is_a?(String)
20
20
  source = args[0]
21
21
  path = args[1]
22
- options = {}
22
+ params = {}
23
23
  else
24
- raise RuntimeError.new("path and source must be of type String; options must be of type Hash")
24
+ raise RuntimeError.new("path and source must be of type String; params must be of type Hash")
25
25
  end
26
26
  when 3
27
27
  source = args[0]
28
28
  path = args[1]
29
- options = args[2]
29
+ params = args[2]
30
30
  else
31
31
  raise RuntimeError.new('path missing')
32
32
  end
33
33
 
34
- imgix_client(source).path(path).to_url(options).html_safe
34
+ imgix_client(source).path(path).to_url(params).html_safe
35
+ end
36
+
37
+ protected
38
+
39
+ def ix_image_srcset(*args)
40
+ validate_configuration!
41
+
42
+ case args.size
43
+ when 1
44
+ path = args[0]
45
+ source = nil
46
+ params = {}
47
+ when 2
48
+ if args[0].is_a?(String) && args[1].is_a?(Hash)
49
+ source = nil
50
+ path = args[0]
51
+ params = args[1]
52
+ elsif args[0].is_a?(String) && args[1].is_a?(String)
53
+ source = args[0]
54
+ path = args[1]
55
+ params = {}
56
+ else
57
+ raise RuntimeError.new("path and source must be of type String; params must be of type Hash")
58
+ end
59
+ when 3
60
+ source = args[0]
61
+ path = args[1]
62
+ params = args[2]
63
+ when 4
64
+ source = args[0]
65
+ path = args[1]
66
+ params = args[2]
67
+ options = args[3]
68
+ else
69
+ raise RuntimeError.new('path missing')
70
+ end
71
+ imgix_client(source).path(path).to_srcset(options: options, **params).html_safe
35
72
  end
36
73
 
37
74
  private
@@ -44,8 +81,8 @@ module Imgix
44
81
  end
45
82
 
46
83
  if imgix[:source]
47
- unless imgix[:source].is_a?(Array) || imgix[:source].is_a?(String)
48
- raise ConfigurationError.new("imgix source must be a String or an Array.")
84
+ unless imgix[:source].is_a?(String)
85
+ raise ConfigurationError.new("imgix source must be a String.")
49
86
  end
50
87
  end
51
88
 
@@ -54,10 +91,6 @@ module Imgix
54
91
  raise ConfigurationError.new(":sources must be a Hash")
55
92
  end
56
93
  end
57
-
58
- unless !imgix.key?(:shard_strategy) || STRATEGIES.include?(imgix[:shard_strategy])
59
- raise ConfigurationError.new("#{imgix[:shard_strategy]} is not supported")
60
- end
61
94
  end
62
95
 
63
96
  def imgix_client(source)
@@ -79,9 +112,7 @@ module Imgix
79
112
  }
80
113
 
81
114
  if imgix[:source].is_a?(String)
82
- opts[:host] = imgix[:source]
83
- else
84
- opts[:hosts] = imgix[:source]
115
+ opts[:domain] = imgix[:source]
85
116
  end
86
117
 
87
118
  if imgix.has_key?(:include_library_param)
@@ -92,15 +123,11 @@ module Imgix
92
123
  opts[:use_https] = imgix[:use_https]
93
124
  end
94
125
 
95
- if imgix.has_key?(:shard_strategy)
96
- opts[:shard_strategy] = imgix[:shard_strategy]
97
- end
98
-
99
126
  sources = imgix[:sources] || { imgix[:source] => imgix[:secure_url_token] }
100
127
  @imgix_clients = {}
101
128
 
102
129
  sources.map do |source, token|
103
- opts[:host] = source
130
+ opts[:domain] = source
104
131
  opts[:secure_url_token] = token
105
132
  @imgix_clients[source] = ::Imgix::Client.new(opts)
106
133
  end
@@ -1,5 +1,5 @@
1
1
  module Imgix
2
2
  module Rails
3
- VERSION = '3.0.2'
3
+ VERSION = '4.1.0'
4
4
  end
5
5
  end
@@ -8,12 +8,12 @@ module Imgix
8
8
  module ViewHelper
9
9
  include UrlHelper
10
10
 
11
- def ix_image_tag(source=nil, path, tag_options: {}, url_params: {}, widths: [])
12
- return Imgix::Rails::ImageTag.new(path, source: source, tag_options: tag_options, url_params: url_params, widths: widths).render
11
+ def ix_image_tag(source=nil, path, tag_options: {}, url_params: {}, srcset_options: {})
12
+ return Imgix::Rails::ImageTag.new(path, source: source, tag_options: tag_options, url_params: url_params, srcset_options: srcset_options).render
13
13
  end
14
14
 
15
- def ix_picture_tag(source=nil, path, tag_options: {}, url_params: {}, breakpoints: {}, widths: [])
16
- return Imgix::Rails::PictureTag.new(path, source: source, tag_options: tag_options, url_params: url_params, breakpoints: breakpoints, widths: widths).render
15
+ def ix_picture_tag(source=nil, path, tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
16
+ return Imgix::Rails::PictureTag.new(path, source: source, tag_options: tag_options, url_params: url_params, breakpoints: breakpoints, srcset_options: srcset_options).render
17
17
  end
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgix-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton
@@ -9,40 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-11-21 00:00:00.000000000 Z
12
+ date: 2020-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: imgix
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.1'
21
18
  - - ">="
22
19
  - !ruby/object:Gem::Version
23
- version: 1.1.0
20
+ version: '3.0'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
24
  requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: '1.1'
31
25
  - - ">="
32
26
  - !ruby/object:Gem::Version
33
- version: 1.1.0
27
+ version: '3.0'
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: bundler
36
30
  requirement: !ruby/object:Gem::Requirement
37
31
  requirements:
38
- - - "~>"
32
+ - - ">="
39
33
  - !ruby/object:Gem::Version
40
34
  version: '1.9'
41
35
  type: :development
42
36
  prerelease: false
43
37
  version_requirements: !ruby/object:Gem::Requirement
44
38
  requirements:
45
- - - "~>"
39
+ - - ">="
46
40
  - !ruby/object:Gem::Version
47
41
  version: '1.9'
48
42
  - !ruby/object:Gem::Dependency
@@ -51,14 +45,14 @@ dependencies:
51
45
  requirements:
52
46
  - - "~>"
53
47
  - !ruby/object:Gem::Version
54
- version: '10.0'
48
+ version: '12.3'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
52
  requirements:
59
53
  - - "~>"
60
54
  - !ruby/object:Gem::Version
61
- version: '10.0'
55
+ version: '12.3'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: rspec
64
58
  requirement: !ruby/object:Gem::Requirement
@@ -97,9 +91,15 @@ executables: []
97
91
  extensions: []
98
92
  extra_rdoc_files: []
99
93
  files:
94
+ - ".github/CODEOWNERS"
95
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
96
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
97
+ - ".github/ISSUE_TEMPLATE/question.md"
98
+ - ".github/pull_request_template.md"
100
99
  - ".gitignore"
101
100
  - ".rspec"
102
101
  - ".travis.yml"
102
+ - CHANGELOG.md
103
103
  - Gemfile
104
104
  - LICENSE
105
105
  - README.md
@@ -119,6 +119,10 @@ homepage: https://github.com/imgix/imgix-rails
119
119
  licenses:
120
120
  - BSD-2-Clause
121
121
  metadata:
122
+ bug_tracker_uri: https://github.com/imgix/imgix-rails/issues
123
+ changelog_uri: https://github.com/imgix/imgix-rails/blob/main/CHANGELOG.md
124
+ documentation_uri: https://www.rubydoc.info/gems/imgix-rails/4.1.0
125
+ source_code_uri: https://github.com/imgix/imgix-rails/tree/v4.1.0
122
126
  allowed_push_host: https://rubygems.org
123
127
  post_install_message:
124
128
  rdoc_options: []
@@ -135,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
139
  - !ruby/object:Gem::Version
136
140
  version: '0'
137
141
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.5.2.3
142
+ rubygems_version: 3.1.2
140
143
  signing_key:
141
144
  specification_version: 4
142
145
  summary: Makes integrating imgix into your Rails app easier. It builds on imgix-rb