imgix-rails 4.0.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1dbb6ad0974d411fd8ab3e7167b211234fc0e96c
4
- data.tar.gz: 0c2717ac27d3323badcc525148188c9716336d2b
2
+ SHA256:
3
+ metadata.gz: a34ec282416d5a7b415af7dc9bfba931814f255834a5c9f7a6bcb2b952ddad77
4
+ data.tar.gz: 1577c493b3d075c351cc087dfb87322d8d9315317fc45a1fd5aa62cc4c033c62
5
5
  SHA512:
6
- metadata.gz: 924e0acf93ae7d7a6b824109261d0fd0e5370323655827c346e5b58e2018ad8341f7e013ddf1a1f402df6aca1da67257fdd6b4fad4d1b08d7e60a644b318cc88
7
- data.tar.gz: 5271ff9cd004e1fe04c7b6ed2d4682891500b7ccb77e3f39229366d83fe162c95f6f0540976f3d52377556cf068a36e6844a40f1aa75de1697488643169aa5d7
6
+ metadata.gz: 22a1dc794c948eb8a38a40b99e0d672a794c33a333be7eb727f9cfe654485c6ed9ead4e5263ebf4f5000f501a9228eac4b22d59c4609a023d153f10bcb4c0c88
7
+ data.tar.gz: 0b7cf4965dde8401b4a6a9b720f55ea557049574d3cb515ab1bde850fa40b5b40b595b0737e75c4fe46480d6c4b81d159d9785e0738fe2be56e9a1c797472623
@@ -0,0 +1,133 @@
1
+ version: 2.1 # Use 2.1 to enable using orbs and other features.
2
+
3
+ orbs:
4
+ ruby: circleci/ruby@1.2.0
5
+ node: circleci/node@2
6
+
7
+ commands:
8
+ rspec:
9
+ parameters:
10
+ out-path:
11
+ default: /tmp/test-results/rspec
12
+ description: >-
13
+ Where to save the rspec.xml file. Will automatically be saved to
14
+ test_results and artifacts on CircleCI.
15
+ type: string
16
+ steps:
17
+ - run:
18
+ command: >
19
+ mkdir -p <<parameters.out-path>>
20
+
21
+ bundle exec rspec --format RspecJunitFormatter --out <<parameters.out-path>>/results.xml --format progress
22
+ name: "Run tests with RSpec"
23
+ - store_test_results:
24
+ path: <<parameters.out-path>>
25
+ - store_artifacts:
26
+ destination: test-results
27
+ path: <<parameters.out-path>>
28
+ # Have to override the command from the ruby orb, since it doesn't support the --add-platform command
29
+ # Since this command wholly comes from the ruby orb, the best documentation can be found at: https://circleci.com/developer/orbs/orb/circleci/ruby
30
+ install-deps:
31
+ description: Install gems with Bundler.
32
+ parameters:
33
+ app-dir:
34
+ default: .
35
+ description: >
36
+ Path to the directory containing your Gemfile file. Not needed if Gemfile
37
+ lives in the root.
38
+ type: string
39
+ bundler-version:
40
+ default: ""
41
+ description: >
42
+ Configure which version of bundler to install and utilize. By default, it
43
+ gets the bundler version from Gemfile.lock, but if it is not working use
44
+ this to override.
45
+ type: string
46
+ key:
47
+ default: gems-v1
48
+ description: The cache key to use. The key is immutable.
49
+ type: string
50
+ path:
51
+ default: ./vendor/bundle
52
+ description: >
53
+ Installation path. By default, it will run bundle with `--deployment` flag
54
+ and installs gems to the vendor/bundle directory.
55
+ type: string
56
+ with-cache:
57
+ default: true
58
+ description: Enable automatic caching of your gemfile dependencies for increased speed.
59
+ type: boolean
60
+ platform:
61
+ default: "x86_64-linux"
62
+ type: string
63
+ steps:
64
+ - when:
65
+ condition: <<parameters.with-cache>>
66
+ steps:
67
+ - restore_cache:
68
+ keys:
69
+ - >-
70
+ << parameters.key >>-{{ checksum
71
+ "<<parameters.app-dir>>/Gemfile" }}-{{ .Branch }}
72
+ - >-
73
+ << parameters.key >>-{{ checksum
74
+ "<<parameters.app-dir>>/Gemfile" }}
75
+ - << parameters.key >>
76
+ - run:
77
+ command: |
78
+
79
+ # we use an pinned bundler version for jruby
80
+ if [ "<< parameters.key >>" == "circleci/jruby:9.2.11.0-node" ]; then
81
+ gem install bundler -v 2.3.26
82
+ else
83
+ gem install bundler
84
+ fi
85
+
86
+ # where we add the platform command to allow CircleCI to bundle
87
+ bundle lock --add-platform <<parameters.platform>>
88
+ if [ "<< parameters.path >>" == "./vendor/bundle" ]; then
89
+ bundle config set deployment 'true'
90
+ fi
91
+ bundle config set path << parameters.path >>
92
+ bundle check || bundle install
93
+ name: >-
94
+ Bundle Install <<^parameters.with-cache>>(No
95
+ Cache)<</parameters.with-cache>>
96
+ working_directory: <<parameters.app-dir>>
97
+ - when:
98
+ condition: <<parameters.with-cache>>
99
+ steps:
100
+ - save_cache:
101
+ key: >-
102
+ << parameters.key >>-{{ checksum
103
+ "<<parameters.app-dir>>/Gemfile" }}-{{ .Branch }}
104
+ paths:
105
+ - <<parameters.app-dir>>/<< parameters.path >>
106
+
107
+ jobs:
108
+ test:
109
+ parameters:
110
+ version:
111
+ default: "cimg/ruby:3.0-node"
112
+ description: Ruby image to use
113
+ type: string
114
+ docker:
115
+ - image: <<parameters.version>>
116
+ steps:
117
+ - checkout
118
+ - install-deps:
119
+ key: <<parameters.version>>
120
+ - rspec
121
+
122
+ workflows:
123
+ version: 2
124
+ test:
125
+ jobs:
126
+ - test:
127
+ matrix:
128
+ parameters:
129
+ version:
130
+ - "cimg/ruby:3.0-node"
131
+ - "cimg/ruby:2.7-node"
132
+ - "cimg/ruby:3.1-node"
133
+ - "circleci/jruby:9.2.11.0-node"
@@ -0,0 +1,2 @@
1
+ # Default owners for repo
2
+ * @imgix/imgix-sdk-team
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ ---
5
+
6
+ **Before you submit:**
7
+
8
+ - [ ] Please read the [contributing guidelines](CONTRIBUTING.md)
9
+ - [ ] Please search through the existing issues (both open AND closed) to see if your issue has been discussed before. Github issue search can be used for this: https://github.com/imgix/vue/issues?utf8=%E2%9C%93&q=is%3Aissue
10
+ - [ ] Please ensure the problem has been isolated and reduced. This link explains more: http://css-tricks.com/6263-reduced-test-cases/
11
+
12
+ **Describe the bug**
13
+ A clear and concise description of what the bug is. Please strive to reach the **root problem** of your issue to avoid the XY problem. See more: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem
14
+
15
+ **To Reproduce**
16
+ A bug is a _demonstrable problem_ that is caused by the code in the repository. Thus, the contributors need a way to reproduce your issue - if we can't reproduce your issue, we can't help you! Also, please be as detailed as possible.
17
+
18
+ [a link to a codesandox or repl.it; here is a link to a codesandbox with @imgix/vue installed which can be forked: https://codesandbox.io/s/vue-imgix-base-codesandbox-bhz8n]
19
+
20
+ [alternatively, please provide a code example]
21
+
22
+ ```js
23
+ // A *self-contained* demonstration of the problem follows...
24
+ // This should be able to be dropped into a file with @imgix/vue installed and just work
25
+ ```
26
+
27
+ Steps to reproduce the behaviour:
28
+
29
+ 1. Go to '...'
30
+ 2. Click on '....'
31
+ 3. Scroll down to '....'
32
+ 4. See error
33
+
34
+ **Expected behaviour**
35
+ A clear and concise description of what you expected to happen.
36
+
37
+ **Screenshots**
38
+ If applicable, add screenshots to help explain your problem.
39
+
40
+ **Information:**
41
+
42
+ - @imgix/vue version: [e.g. v1.0]
43
+ - browser version: [include link from [https://www.whatsmybrowser.org/](https://www.whatsmybrowser.org/) or details about the OS used and browser version]
44
+
45
+ **Additional context**
46
+ Add any other context about the problem here.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ ---
5
+
6
+ **Before you submit:**
7
+
8
+ - [ ] Please read the [contributing guidelines](CONTRIBUTING.md)
9
+ - [ ] Please search through the existing issues (both open AND closed) to see if your feature has already been discussed. Github issue search can be used for this: https://github.com/imgix/vue/issues?utf8=%E2%9C%93&q=is%3Aissue
10
+ - [ ] Please take a moment to find out whether your idea fits with the scope and aims of the project
11
+
12
+ **Is your feature request related to a problem? Please describe.**
13
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
14
+
15
+ **Describe the solution you'd like**
16
+ A clear and concise description of how this feature would function.
17
+
18
+ **Describe alternatives you've considered**
19
+ A clear and concise description of any alternative solutions or features you've considered.
20
+
21
+ **Additional context**
22
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: Question
3
+ about: Ask a question about the project
4
+ ---
5
+
6
+ **Before you submit:**
7
+
8
+ - [ ] Please read the [contributing guidelines](CONTRIBUTING.md)
9
+ - [ ] Please search through the existing issues (both open AND closed) to see if your question has already been discussed. Github issue search can be used for this: https://github.com/imgix/vue/issues?utf8=%E2%9C%93&q=is%3Aissue
10
+
11
+ **Question**
12
+ A clear and concise description of your question
@@ -0,0 +1,36 @@
1
+ <!--
2
+ Hello, and thanks for contributing 🎉🙌
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
9
+ controversial in your PR, please take a moment to tell us about your choices.-->
10
+
11
+ <!-- Before this PR... -->
12
+
13
+ <!-- After this PR... -->
14
+
15
+ <!-- Steps to test: either provide a code snippet that exhibits this change or a link to a codepen/codesandbox demo -->
16
+
17
+ ## Checklist
18
+
19
+ <!-- Please ensure you've completed this checklist before submitting a PR. If
20
+ You're not submitting a bugfix or feature, delete that part of the checklist.
21
+ -->
22
+
23
+ <!-- For all Pull Requests -->
24
+
25
+ - [ ] Read the [contributing guidelines](CONTRIBUTING.md).
26
+ - [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) spec format.
27
+ - [ ] Update the readme (if applicable).
28
+ - [ ] Update or add any necessary API documentation (if applicable)
29
+ - [ ] All existing unit tests are still passing (if applicable).
30
+
31
+ <!-- For new feature and bugfix Pull Requests-->
32
+
33
+ - [ ] Add some [steps](#steps-to-test) so we can test your bug fix or feature (if applicable).
34
+ - [ ] Add new passing unit tests to cover the code introduced by your PR (if applicable).
35
+ - [ ] Any breaking changes are specified on the commit on which they are introduced with `BREAKING CHANGE` in the body of the commit.
36
+ - [ ] If this is a big feature with breaking changes, consider opening an issue to discuss first. This is completely up to you, but please keep in mind that your PR might not be accepted.
@@ -0,0 +1,16 @@
1
+ name: Add issues to project
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ add-to-project:
10
+ name: Add issue to project
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/add-to-project@v0.3.0
14
+ with:
15
+ project-url: https://github.com/orgs/imgix/projects/4
16
+ github-token: ${{ secrets.GH_TOKEN }}
@@ -0,0 +1,16 @@
1
+ name: Add needs-review and size/XL pull requests to projects
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ add-to-project:
10
+ name: Add issue to project
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/add-to-project@v0.3.0
14
+ with:
15
+ project-url: https://github.com/orgs/imgix/projects/4
16
+ github-token: ${{ secrets.GH_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -3,7 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
- # [4.0.0](https://github.com/imgix/imgix-rb/compare/3.1.0...4.0.0) - December 03, 2019
6
+ ## [4.3.1](https://github.com/imgix/imgix-rb/compare/4.3.0...4.3.1) - January 30, 2023
7
+
8
+ - Allow disabling path encoding in ix_image_url ([#125] (https://github.com/imgix/imgix-rails/pull/125))
9
+
10
+ ## [4.3.0](https://github.com/imgix/imgix-rb/compare/4.2.0...4.3.0) - December 14, 2022
11
+
12
+ - Add img_tag_options to ix_picture_tag ([#118] (https://github.com/imgix/imgix-rails/pull/118))
13
+
14
+ ## [4.2.0](https://github.com/imgix/imgix-rb/compare/4.1.0...4.2.0) - January 05, 2021
15
+
16
+ - Add support for lazy image loading ([#108](https://github.com/imgix/imgix-rails/pull/108))
17
+
18
+ ## [4.1.0](https://github.com/imgix/imgix-rb/compare/4.0.2...4.1.0) - October 13, 2020
19
+
20
+ ### Release Notes
21
+
22
+ 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.
23
+
24
+ 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).
25
+
26
+ To upgrade to the new purging API used in `imgix '~> 4.0'`:
27
+
28
+ - navigate to the [API Keys](https://dashboard.imgix.com/api-keys) portion of your dashboard
29
+ - generate a new API Key
30
+ - use this new key in your imgix client: `Imgix::Client.new(domain: '...', api_key: NEW_API_KEY)`
31
+
32
+ ### Changes
33
+
34
+ - build: use optimistic constraint for imgix >= 3.0 ([#104](https://github.com/imgix/imgix-rails/pull/104))
35
+
36
+ ## [4.0.2](https://github.com/imgix/imgix-rb/compare/4.0.1...4.0.2) - July 31, 2020
37
+
38
+ - fix: replace `opts[:host`] with `opts[:domain]` to resolve deprecation warnings ([#96](https://github.com/imgix/imgix-rails/pull/96))
39
+
40
+ ## [4.0.1](https://github.com/imgix/imgix-rb/compare/4.0.0...4.0.1) - June 10, 2020
41
+
42
+ - fix: update rake version ([#94](https://github.com/imgix/imgix-rails/pull/94))
43
+
44
+ ## [4.0.0](https://github.com/imgix/imgix-rb/compare/3.1.0...4.0.0) - December 03, 2019
7
45
 
8
46
  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:
9
47
 
@@ -17,13 +55,13 @@ For users migrating to version 4.0 or later, it is important that all srcset-rel
17
55
 
18
56
  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.
19
57
 
20
- * feat: utilize Imgix::Path#to_srcset when constructing srcsets ([#83](https://github.com/imgix/imgix-rails/pull/83))
21
- * chore: remove deprecated domain sharding behavior ([#80](https://github.com/imgix/imgix-rails/pull/80))
22
- * fix: deprecate resizing height when maintaining aspect ratio ([#78](https://github.com/imgix/imgix-rails/pull/78))
58
+ - feat: utilize Imgix::Path#to_srcset when constructing srcsets ([#83](https://github.com/imgix/imgix-rails/pull/83))
59
+ - chore: remove deprecated domain sharding behavior ([#80](https://github.com/imgix/imgix-rails/pull/80))
60
+ - fix: deprecate resizing height when maintaining aspect ratio ([#78](https://github.com/imgix/imgix-rails/pull/78))
23
61
 
24
62
  ## [3.1.0](https://github.com/imgix/imgix-rb/compare/3.0.2...3.1.0) - October 25, 2019
25
63
 
26
- * Update bundler dev dependency to include new major version 2.x ([#71](https://github.com/imgix/imgix-rb/pull/71))
27
- * README: Fix typo ([#73](https://github.com/imgix/imgix-rb/pull/73))
28
- * docs: add ActiveStorage instructions to README ([#74](https://github.com/imgix/imgix-rb/pull/74))
29
- * 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))
64
+ - Update bundler dev dependency to include new major version 2.x ([#71](https://github.com/imgix/imgix-rb/pull/71))
65
+ - README: Fix typo ([#73](https://github.com/imgix/imgix-rb/pull/73))
66
+ - docs: add ActiveStorage instructions to README ([#74](https://github.com/imgix/imgix-rb/pull/74))
67
+ - 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))
@@ -0,0 +1,3 @@
1
+ # Code of Conduct
2
+
3
+ Please read the imgix [Code of Conduct](https://github.com/imgix/code-of-conduct).
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,108 @@
1
+ # Contributing Guide
2
+
3
+ Thank you for investing your time in contributing to this project! Please take a moment to review this document in order to streamline the contribution process for you and any reviewers involved.
4
+
5
+ Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable.
6
+
7
+ In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR.
8
+
9
+ ## New contributor guide
10
+
11
+ To get an overview of the project, read the [README](README.md). Here are some resources to help you get started with open source contributions:
12
+
13
+ - [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
14
+ - [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
15
+ - [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
16
+ - [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)
17
+
18
+ ## Opening a Pull Request
19
+
20
+ _To help the project's maintainers and community quickly understand the nature of your pull request, please be sure to do the following:_
21
+
22
+ 1. Include a descriptive Pull Request title.
23
+ 2. Provide a detailed description that explains the nature of the change(s) introduced. This is not only helpful for your reviewer, but also for future users who may need to revisit your Pull Request for context purposes. Screenshots/video captures are helpful here!
24
+ 3. Make incremental, modular changes, with a clean commit history. This helps reviewers understand your contribution more easily and maintain project quality.
25
+
26
+ ### Checklist
27
+
28
+ Check to see that you have completed each of the following before requesting a review of your Pull Request:
29
+
30
+ - [ ] All existing unit tests are still passing (if applicable)
31
+ - [ ] Add new passing unit tests to cover the code introduced by your PR
32
+ - [ ] Update the README
33
+ - [ ] Update or add any necessary API documentation
34
+ - [ ] All commits in the branch adhere to the [conventional commit](#conventional-commit-spec) format: e.g. `fix: bug #issue-number`
35
+
36
+ ## Conventional Commit Spec
37
+
38
+ Commits should be in the format `<type>(<scope>): <description>`. This allows our team to leverage tooling for automatic releases and changelog generation. An example of a commit in this format might be: `docs(readme): fix typo in documentation`
39
+
40
+ `type` can be any of the follow:
41
+
42
+ - `feat`: a feature, or breaking change
43
+ - `fix`: a bug-fix
44
+ - `test`: Adding missing tests or correcting existing tests
45
+ - `docs`: documentation only changes (readme, changelog, contributing guide)
46
+ - `refactor`: a code change that neither fixes a bug nor adds a feature
47
+ - `chore`: reoccurring tasks for project maintainability (example scopes: release, deps)
48
+ - `config`: changes to tooling configurations used in the project
49
+ - `build`: changes that affect the build system or external dependencies (example scopes: npm, bundler, gradle)
50
+ - `ci`: changes to CI configuration files and scripts (example scopes: travis)
51
+ - `perf`: a code change that improves performance
52
+ - `style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
53
+
54
+ `scope` is optional, and can be anything.
55
+ `description` should be a short description of the change, written in the imperative-mood.
56
+
57
+ ### Example workflow
58
+
59
+ Follow this process if you'd like your work considered for inclusion in the
60
+ project:
61
+
62
+ 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
63
+ and configure the remotes:
64
+
65
+ ```bash
66
+ # Clone your fork of the repo into the current directory
67
+ git clone git@github.com:<YOUR_USERNAME>/imgix-rails.git
68
+ # Navigate to the newly cloned directory
69
+ cd imgix-rails
70
+ # Assign the original repo to a remote called "upstream"
71
+ git remote add upstream https://github.com/imgix/imgix-rails
72
+ ```
73
+
74
+ 2. If you cloned a while ago, get the latest changes from upstream:
75
+
76
+ ```bash
77
+ git checkout <dev-branch>
78
+ git pull upstream <dev-branch>
79
+ ```
80
+
81
+ 3. Create a new topic branch (off the main project development branch) to
82
+ contain your feature, change, or fix:
83
+
84
+ ```bash
85
+ git checkout -b <topic-branch-name>
86
+ ```
87
+
88
+ 4. Commit your changes in logical chunks. Use Git's
89
+ [interactive rebase](https://help.github.com/articles/interactive-rebase)
90
+ feature to tidy up your commits before making them public.
91
+
92
+ 5. Locally merge (or rebase) the upstream development branch into your topic branch:
93
+
94
+ ```bash
95
+ git pull [--rebase] upstream <dev-branch>
96
+ ```
97
+
98
+ 6. Push your topic branch up to your fork:
99
+
100
+ ```bash
101
+ git push origin <topic-branch-name>
102
+ ```
103
+
104
+ 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
105
+ with a clear title and description.
106
+
107
+ **IMPORTANT**: By submitting a patch, you agree to allow the project owner to
108
+ license your work under the same license as that used by the project.
data/README.md CHANGED
@@ -1,54 +1,64 @@
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. It is tested under Ruby versions `3.1`, `3.0`, `2.7`, and `jruby-9.2.11.0`.
5
+
6
+ [![Gem Version](https://img.shields.io/gem/v/imgix-rails.svg)](https://rubygems.org/gems/imgix-rails)
7
+ [![Build Status](https://circleci.com/gh/imgix/imgix-rails.svg?style=shield)](https://circleci.com/gh/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
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rails.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rails?ref=badge_shield)
11
+
12
+ ---
13
+ <!-- /ix-docs-ignore -->
14
+
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ * [Configuration](#configuration)
18
+ + [Multi-source configuration](#multi-source-configuration)
19
+ * [`ix_image_tag`](#ix_image_tag)
20
+ + [Fixed image rendering](#fixed-image-rendering)
21
+ + [Lazy loading](#lazy-loading)
22
+ * [`ix_picture_tag`](#ix_picture_tag)
23
+ * [`ix_image_url`](#ix_image_url)
24
+ + [Usage in Model](#usage-in-model)
25
+ + [Usage in Sprockets](#usage-in-sprockets)
26
+ - [Using With Image Uploading Libraries](#using-with-image-uploading-libraries)
27
+ * [Paperclip and CarrierWave](#paperclip-and-carrierwave)
28
+ * [Refile](#refile)
29
+ * [Active Storage](#active-storage)
30
+ * [S3](#s3)
31
+ * [GCS](#gcs)
32
+ - [Upgrade Guides](#upgrade-guides)
33
+ * [3.x to 4.0](#3x-to-40)
34
+ - [Development](#development)
35
+ - [Contributing](#contributing)
36
+ - [Code of Conduct](#code-of-conduct)
37
+ - [License](#license)
2
38
 
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 [Active Storage](https://github.com/rails/rails/tree/master/activestorage) 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
- * [Active Storage](#activestorage)
22
- * [Upgrade Guides](#upgrade-guides)
23
- * [Development](#development)
24
- * [Contributing](#contributing)
25
-
26
-
27
- <a name="installation"></a>
28
39
  ## Installation
29
40
 
30
41
  Add this line to your application's Gemfile:
31
42
 
32
- ```ruby
43
+ ```rb
33
44
  gem 'imgix-rails'
34
45
  ```
35
46
 
36
47
  And then execute:
37
48
 
38
- $ bundle
39
-
49
+ ```bash
50
+ $ bundle
51
+ ```
40
52
 
41
- <a name="usage"></a>
42
53
  ## Usage
43
54
 
44
55
  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.
45
56
 
46
- <a name="configuration"></a>
47
57
  ### Configuration
48
58
 
49
59
  Before you get started, you will need to define your imgix configuration in your `config/application.rb`, or in an environment-specific configuration file.
50
60
 
51
- ```ruby
61
+ ```rb
52
62
  Rails.application.configure do
53
63
  config.imgix = {
54
64
  source: "assets.imgix.net"
@@ -62,6 +72,7 @@ The following configuration flags will be respected:
62
72
  - `source`: a String or Array that specifies the imgix Source address. Should be in the form of `"assets.imgix.net"`.
63
73
  - `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%`).
64
74
  - `secure_url_token`: an optional secure URL token found in your dashboard (https://dashboard.imgix.com) used for signing requests
75
+ - `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`.
65
76
 
66
77
  #### Multi-source configuration
67
78
 
@@ -72,7 +83,7 @@ In addition to the standard configuration flags, the following options can be us
72
83
 
73
84
  Example:
74
85
 
75
- ```ruby
86
+ ```rb
76
87
  Rails.application.configure do
77
88
  config.imgix = {
78
89
  sources: {
@@ -84,8 +95,7 @@ Rails.application.configure do
84
95
  end
85
96
  ```
86
97
 
87
- <a name="ix_image_tag"></a>
88
- ### ix_image_tag
98
+ ### `ix_image_tag`
89
99
 
90
100
  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).
91
101
 
@@ -102,6 +112,8 @@ The `ix_image_tag` helper method makes it easy to pass parameters to imgix to ha
102
112
  * [`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.
103
113
  * [`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.
104
114
  * [`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`.
115
+ * `attribute_options`: Allow you to change where imgix-rails renders
116
+ attributes. This can be helpful if you want to add lazy-loading.
105
117
 
106
118
  ```erb
107
119
  <%= 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' }) %>
@@ -133,7 +145,7 @@ Will generate URLs using `assets2.imgix.net` source.
133
145
 
134
146
  We recommend leveraging this to generate powerful helpers within your application like the following:
135
147
 
136
- ```ruby
148
+ ```rb
137
149
  def profile_image_tag(user)
138
150
  ix_image_tag(user.profile_image_url, url_params: { w: 100, h: 200, fit: 'crop' })
139
151
  end
@@ -171,8 +183,30 @@ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=5&amp;q=
171
183
 
172
184
  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 }`.
173
185
 
174
- <a name="ix_picture_tag"></a>
175
- ### ix_picture_tag
186
+ #### Lazy loading
187
+
188
+ If you'd like to lazy load images, we recommend using [lazysizes](https://github.com/aFarkas/lazysizes). In order to use imgix-rails with lazysizes, you need to use `attribute_options` as well as set `tag_options[:src]`:
189
+
190
+ ```erb
191
+ <%= ix_image_tag('image.jpg', attribute_options: {src: "data-src",
192
+ srcset: "data-srcset", sizes: "data-sizes"}, url_params: {w: 1000},
193
+ tag_options: {src: "lqip.jpg"}) %>
194
+ ```
195
+
196
+ Will render the following HTML:
197
+
198
+ ```html
199
+ <img data-srcset="https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=1&amp;q=75 1x,
200
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=2&amp;q=50 2x,
201
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=3&amp;q=35 3x,
202
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=4&amp;q=23 4x,
203
+ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000&amp;dpr=5&amp;q=20 5x"
204
+ data-sizes="100vw"
205
+ data-src="https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&amp;w=1000"
206
+ src="lqip.jpg">
207
+ ```
208
+
209
+ ### `ix_picture_tag`
176
210
 
177
211
  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.
178
212
 
@@ -181,6 +215,7 @@ The `ix_picture_tag` helper method makes it easy to generate `picture` elements
181
215
  * `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.
182
216
  * `path`: The path or URL of the image to display.
183
217
  * `tag_options`: Any options to apply to the parent `picture` element. This is useful for adding class names, etc.
218
+ * `img_tag_options`: Any options to apply to the generated `img` element. This can be useful to add an `alt` attribute.
184
219
  * `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`.
185
220
  * `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.
186
221
  * `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:
@@ -194,6 +229,9 @@ The `ix_picture_tag` helper method makes it easy to generate `picture` elements
194
229
  tag_options: {
195
230
  class: 'a-picture-tag'
196
231
  },
232
+ img_tag_options: {
233
+ alt: 'A picture of Bert and Ernie arguing'
234
+ },
197
235
  url_params: {
198
236
  w: 300,
199
237
  h: 300,
@@ -233,6 +271,7 @@ To generate a `picture` element on a different source:
233
271
  ```erb
234
272
  <%= ix_picture_tag('assets2.imgix.net', 'bertandernie.jpg',
235
273
  tag_options: {},
274
+ img_tag_options: {},
236
275
  url_params: {},
237
276
  breakpoints: {
238
277
  '(max-width: 640px)' => {
@@ -243,20 +282,19 @@ To generate a `picture` element on a different source:
243
282
  ) %>
244
283
  ```
245
284
 
246
- <a name="ix_image_url"></a>
247
- ### ix_image_url
285
+ ### `ix_image_url`
248
286
 
249
287
  The `ix_image_url` helper makes it easy to generate a URL to an image in your Rails app.
250
288
 
251
- `ix_image_url` takes four arguments:
289
+ `ix_image_url` takes three arguments:
252
290
 
253
291
  * `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.
254
292
  * `path`: The path or URL of the image to display.
255
- * `options`: The imgix URL parameters to apply to this image URL.
293
+ * `options`: The imgix URL parameters to apply to this image URL. Optionally, you can use `disable_path_encoding: false` for disabling URL-encoding which will be applied by default.
256
294
 
257
295
  ```erb
258
296
  <%= ix_image_url('/users/1/avatar.png', { w: 400, h: 300 }) %>
259
- <%= ix_image_url('assets2.imgix.net', '/users/1/avatar.png', { w: 400, h: 300 }) %>
297
+ <%= ix_image_url('assets2.imgix.net', '/users/1/avatar.png', { w: 400, h: 300, disable_path_encoding: true }) %>
260
298
  ```
261
299
 
262
300
  Will generate the following URLs:
@@ -266,16 +304,19 @@ https://assets.imgix.net/users/1/avatar.png?w=400&h=300
266
304
  https://assets2.imgix.net/users/1/avatar.png?w=400&h=300
267
305
  ```
268
306
 
307
+ #### Usage in Model
308
+
269
309
  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.
270
310
 
271
- ```ruby
311
+ ```rb
272
312
  include Imgix::Rails::UrlHelper
273
313
 
274
314
  puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
275
315
  # => https://assets.imgix.net/users/1/avatar.png?w=400&h=300
276
316
  ```
277
317
 
278
- <a name="usage-in-sprockets"></a>
318
+ Alternatively, you can also use the imgix [Ruby client](https://github.com/imgix/imgix-rb) in the same way.
319
+
279
320
  #### Usage in Sprockets
280
321
 
281
322
  `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:
@@ -286,13 +327,10 @@ puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
286
327
  }
287
328
  ```
288
329
 
289
- <a name="using-with-image-uploading-libraries"></a>
290
330
  ## Using With Image Uploading Libraries
291
331
 
292
332
  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!
293
333
 
294
-
295
- <a name="paperclip-and-carrierwave"></a>
296
334
  ### Paperclip and CarrierWave
297
335
 
298
336
  Paperclip and CarrierWave can directly provide paths to uploaded images, so we can use them with imgix-rails without a bridge.
@@ -301,8 +339,6 @@ Paperclip and CarrierWave can directly provide paths to uploaded images, so we c
301
339
  <%= ix_image_tag(@user.avatar.path, { auto: 'format', fit: 'crop', w: 500}) %>
302
340
  ```
303
341
 
304
-
305
- <a name="refile"></a>
306
342
  ### Refile
307
343
 
308
344
  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.
@@ -333,12 +369,13 @@ end
333
369
  <%= ix_refile_image_tag(@blog_post, :hero_photo, {auto: 'format', fit: 'crop', w: 500}) %>
334
370
  ```
335
371
 
336
- <a name="activestorage"></a>
337
372
  ### Active Storage
338
373
 
339
374
  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.
340
375
 
341
- #### config/storage.yml
376
+ ### S3
377
+ **config/storage.yml**
378
+
342
379
  ```yml
343
380
  service: S3
344
381
  access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
@@ -347,17 +384,34 @@ region: us-east-1
347
384
  bucket: your_own_bucket
348
385
  ```
349
386
 
350
- 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:
387
+ ### GCS
388
+ ```yml
389
+ google:
390
+ service: GCS
391
+ project: Project Name
392
+ credentials: <%= Rails.root.join("path/to/key.json") %>
393
+ bucket: Bucket Name
394
+ ```
351
395
 
352
- #### config/environments/production.rb
353
- ```ruby
396
+ 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:
397
+
398
+ **config/environments/production.rb**
399
+
400
+ ```rb
354
401
  config.active_storage.service = :amazon
355
402
  ```
356
403
 
404
+ To use Google GCS in production, configure the active storage service like so:
405
+
406
+ ```rb
407
+ config.active_storage.service = :google
408
+ ```
409
+
357
410
  As you would normally with imgix-rails, configure your application to point to your imgix source:
358
411
 
359
- #### config/application.rb
360
- ```ruby
412
+ **config/application.rb**
413
+
414
+ ```rb
361
415
  Rails.application.configure do
362
416
  config.imgix = {
363
417
  source: your_domain,
@@ -369,12 +423,12 @@ end
369
423
 
370
424
  Finally, the two can be used together by passing in the filename of the ActiveStorage blob into the imgix-rails helper function:
371
425
 
372
- #### show.html.erb
426
+ **show.html.erb**
427
+
373
428
  ```erb
374
429
  <%= ix_image_tag(@your_model.image.key) %>
375
430
  ```
376
431
 
377
- <a name="upgrade-guides"></a>
378
432
  ## Upgrade Guides
379
433
 
380
434
  ### 3.x to 4.0
@@ -391,22 +445,18 @@ For users migrating to version 4.0 or later, it is important that all srcset-rel
391
445
 
392
446
  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.
393
447
 
394
- <a name="development"></a>
395
448
  ## Development
396
449
 
397
450
  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.
398
451
 
399
452
  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).
400
453
 
401
-
402
- <a name="contributing"></a>
403
454
  ## Contributing
404
455
 
405
- 1. Fork it ( https://github.com/[my-github-username]/imgix-rails/fork )
406
- 2. Create your feature branch (`git checkout -b my-new-feature`)
407
- 3. Commit your changes (`git commit -am 'Add some feature'`)
408
- 4. Push to the branch (`git push origin my-new-feature`)
409
- 5. Create a new Pull Request
456
+ See [contributing guidelines](CONTRIBUTING.md).
410
457
 
411
458
  ## Code of Conduct
412
459
  Users contributing to or participating in the development of this project are subject to the terms of imgix's [Code of Conduct](https://github.com/imgix/code-of-conduct).
460
+
461
+ ## License
462
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rails.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rails?ref=badge_large)
data/imgix-rails.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata = {
18
18
  'bug_tracker_uri' => 'https://github.com/imgix/imgix-rails/issues',
19
- 'changelog_uri' => 'https://github.com/imgix/imgix-rails/blob/master/CHANGELOG.md',
19
+ 'changelog_uri' => 'https://github.com/imgix/imgix-rails/blob/main/CHANGELOG.md',
20
20
  'documentation_uri' => "https://www.rubydoc.info/gems/imgix-rails/#{spec.version}",
21
21
  'source_code_uri' => "https://github.com/imgix/imgix-rails/tree/v#{spec.version}"
22
22
  }
@@ -33,10 +33,11 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ["lib"]
35
35
 
36
- spec.add_runtime_dependency "imgix", "~> 3.0"
36
+ spec.add_runtime_dependency "imgix", ">= 3.0"
37
37
 
38
38
  spec.add_development_dependency "bundler", ">=1.9"
39
- spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rake", "~> 12.3"
40
40
  spec.add_development_dependency "rspec"
41
41
  spec.add_development_dependency "rspec-rails"
42
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
42
43
  end
@@ -3,9 +3,28 @@ require "imgix/rails/tag"
3
3
  class Imgix::Rails::ImageTag < Imgix::Rails::Tag
4
4
 
5
5
  def render
6
- @tag_options[:srcset] = srcset
7
- @tag_options[:sizes] ||= '100vw'
6
+ url = ix_image_url(@source, @path, @url_params)
8
7
 
9
- image_tag(ix_image_url(@source, @path, @url_params), @tag_options)
8
+ if @attribute_options[:srcset].present?
9
+ @tag_options[@attribute_options[:srcset]] = srcset
10
+ else
11
+ @tag_options[:srcset] = srcset
12
+ end
13
+
14
+ if @attribute_options[:size].present?
15
+ @tag_options[@attribute_options[:size]] ||= '100vw'
16
+ else
17
+ @tag_options[:sizes] ||= '100vw'
18
+ end
19
+
20
+ if @attribute_options[:src].present?
21
+ @tag_options[@attribute_options[:src]] = url
22
+ end
23
+
24
+ if @tag_options[:src].present?
25
+ image_tag(@tag_options[:src], @tag_options)
26
+ else
27
+ image_tag(url, @tag_options)
28
+ end
10
29
  end
11
30
  end
@@ -5,10 +5,11 @@ require "action_view"
5
5
  class Imgix::Rails::PictureTag < Imgix::Rails::Tag
6
6
  include ActionView::Context
7
7
 
8
- def initialize(path, source: nil, tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
8
+ def initialize(path, source: nil, tag_options: {}, img_tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
9
9
  @path = path
10
10
  @source = source
11
11
  @tag_options = tag_options
12
+ @img_tag_options = img_tag_options
12
13
  @url_params = url_params
13
14
  @breakpoints = breakpoints
14
15
  @srcset_options = srcset_options
@@ -28,7 +29,7 @@ class Imgix::Rails::PictureTag < Imgix::Rails::Tag
28
29
  concat(content_tag(:source, nil, source_tag_opts))
29
30
  end
30
31
 
31
- concat Imgix::Rails::ImageTag.new(@path, source: @source, url_params: @url_params, srcset_options: @srcset_options).render
32
+ concat Imgix::Rails::ImageTag.new(@path, source: @source, tag_options: @img_tag_options, url_params: @url_params, srcset_options: @srcset_options).render
32
33
  end
33
34
  end
34
35
 
@@ -5,12 +5,13 @@ class Imgix::Rails::Tag
5
5
  include Imgix::Rails::UrlHelper
6
6
  include ActionView::Helpers
7
7
 
8
- def initialize(path, source: nil, tag_options: {}, url_params: {}, srcset_options: {})
8
+ def initialize(path, source: nil, tag_options: {}, url_params: {}, srcset_options: {}, attribute_options: {})
9
9
  @path = path
10
10
  @source = source
11
11
  @tag_options = tag_options
12
12
  @url_params = url_params
13
13
  @srcset_options = srcset_options
14
+ @attribute_options = attribute_options
14
15
  end
15
16
 
16
17
  protected
@@ -6,6 +6,8 @@ module Imgix
6
6
  def ix_image_url(*args)
7
7
  validate_configuration!
8
8
 
9
+ disable_path_encoding = args.last.is_a?(Hash) && args.last.delete(:disable_path_encoding)
10
+
9
11
  case args.size
10
12
  when 1
11
13
  path = args[0]
@@ -31,7 +33,7 @@ module Imgix
31
33
  raise RuntimeError.new('path missing')
32
34
  end
33
35
 
34
- imgix_client(source).path(path).to_url(params).html_safe
36
+ imgix_client(source).path(path).to_url(params, disable_path_encoding: disable_path_encoding).html_safe
35
37
  end
36
38
 
37
39
  protected
@@ -112,7 +114,7 @@ module Imgix
112
114
  }
113
115
 
114
116
  if imgix[:source].is_a?(String)
115
- opts[:host] = imgix[:source]
117
+ opts[:domain] = imgix[:source]
116
118
  end
117
119
 
118
120
  if imgix.has_key?(:include_library_param)
@@ -127,7 +129,7 @@ module Imgix
127
129
  @imgix_clients = {}
128
130
 
129
131
  sources.map do |source, token|
130
- opts[:host] = source
132
+ opts[:domain] = source
131
133
  opts[:secure_url_token] = token
132
134
  @imgix_clients[source] = ::Imgix::Client.new(opts)
133
135
  end
@@ -1,5 +1,5 @@
1
1
  module Imgix
2
2
  module Rails
3
- VERSION = '4.0.0'
3
+ VERSION = '4.3.1'
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: {}, srcset_options: {})
12
- return Imgix::Rails::ImageTag.new(path, source: source, tag_options: tag_options, url_params: url_params, srcset_options: srcset_options).render
11
+ def ix_image_tag(source=nil, path, tag_options: {}, url_params: {}, srcset_options: {}, attribute_options: {})
12
+ return Imgix::Rails::ImageTag.new(path, source: source, tag_options: tag_options, url_params: url_params, srcset_options: srcset_options, attribute_options: attribute_options).render
13
13
  end
14
14
 
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
15
+ def ix_picture_tag(source=nil, path, tag_options: {}, img_tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
16
+ return Imgix::Rails::PictureTag.new(path, source: source, tag_options: tag_options, img_tag_options: img_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,28 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgix-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton
8
8
  - Paul Straw
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-12-03 00:00:00.000000000 Z
12
+ date: 2023-01-30 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
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.0'
28
28
  - !ruby/object:Gem::Dependency
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '10.0'
48
+ version: '12.3'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '10.0'
55
+ version: '12.3'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec_junit_formatter
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.4.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.4.1
84
98
  description: Makes integrating imgix into your Rails app easier. It builds on imgix-rb
85
99
  to offer a few Rails-specific interfaces. Please see https://github.com/imgix/imgix-rails
86
100
  for more details.
@@ -91,10 +105,19 @@ executables: []
91
105
  extensions: []
92
106
  extra_rdoc_files: []
93
107
  files:
108
+ - ".circleci/config.yml"
109
+ - ".github/CODEOWNERS"
110
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
111
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
112
+ - ".github/ISSUE_TEMPLATE/question.md"
113
+ - ".github/pull_request_template.md"
114
+ - ".github/workflows/add-issue-to-project.yml"
115
+ - ".github/workflows/add-pr-to-project.yml"
94
116
  - ".gitignore"
95
117
  - ".rspec"
96
- - ".travis.yml"
97
118
  - CHANGELOG.md
119
+ - CODE-OF-CONDUCT.md
120
+ - CONTRIBUTING.md
98
121
  - Gemfile
99
122
  - LICENSE
100
123
  - README.md
@@ -115,11 +138,11 @@ licenses:
115
138
  - BSD-2-Clause
116
139
  metadata:
117
140
  bug_tracker_uri: https://github.com/imgix/imgix-rails/issues
118
- changelog_uri: https://github.com/imgix/imgix-rails/blob/master/CHANGELOG.md
119
- documentation_uri: https://www.rubydoc.info/gems/imgix-rails/4.0.0
120
- source_code_uri: https://github.com/imgix/imgix-rails/tree/v4.0.0
141
+ changelog_uri: https://github.com/imgix/imgix-rails/blob/main/CHANGELOG.md
142
+ documentation_uri: https://www.rubydoc.info/gems/imgix-rails/4.3.1
143
+ source_code_uri: https://github.com/imgix/imgix-rails/tree/v4.3.1
121
144
  allowed_push_host: https://rubygems.org
122
- post_install_message:
145
+ post_install_message:
123
146
  rdoc_options: []
124
147
  require_paths:
125
148
  - lib
@@ -134,9 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
157
  - !ruby/object:Gem::Version
135
158
  version: '0'
136
159
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.6.13
139
- signing_key:
160
+ rubygems_version: 3.2.33
161
+ signing_key:
140
162
  specification_version: 4
141
163
  summary: Makes integrating imgix into your Rails app easier. It builds on imgix-rb
142
164
  to offer a few Rails-specific interfaces.
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.1
4
- - 2.2.5
5
- - jruby
6
- script: bundle exec rspec