imgix-rails 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -1
- data/README.md +53 -58
- data/imgix-rails.gemspec +1 -1
- data/lib/imgix/rails/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '091eb91868dd59d79ea87e37b180a14a8223ff545cd6d72c6e2d2ad07c3187fe'
|
4
|
+
data.tar.gz: 4509b927b6bb48013f709da6e616bd2c79557864498796380c3694ced17e2a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e897e5aa09cd7b25156891893d07456ddcc764376cc76022a27561fa69f785e7cbe88d9791b051f3d77bf35738a8e4cbbac73b9bdd6b8d98eb38b8607d5c7a
|
7
|
+
data.tar.gz: c0381d48f5cf4e21b70fa07949d271ce61bb651af4a9d7ef2571ccb274956340f8d2f4060cdc835588ee6823b6083f99210a321f8decd47bffafe0049dbbff73
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,11 @@
|
|
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
|
-
|
6
|
+
## [4.0.1](https://github.com/imgix/imgix-rb/compare/4.0.0...4.0.1) - June 10, 2020
|
7
|
+
|
8
|
+
- fix: update rake version ([#94](https://github.com/imgix/imgix-rails/pull/94))
|
9
|
+
|
10
|
+
## [4.0.0](https://github.com/imgix/imgix-rb/compare/3.1.0...4.0.0) - December 03, 2019
|
7
11
|
|
8
12
|
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
13
|
|
data/README.md
CHANGED
@@ -1,54 +1,58 @@
|
|
1
|
-
|
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=master)](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/master/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
|
+
- [Upgrade Guides](#upgrade-guides)
|
28
|
+
- [3.x to 4.0](#3x-to-40)
|
29
|
+
- [Development](#development)
|
30
|
+
- [Contributing](#contributing)
|
31
|
+
- [Code of Conduct](#code-of-conduct)
|
2
32
|
|
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
33
|
## Installation
|
29
34
|
|
30
35
|
Add this line to your application's Gemfile:
|
31
36
|
|
32
|
-
```
|
37
|
+
```rb
|
33
38
|
gem 'imgix-rails'
|
34
39
|
```
|
35
40
|
|
36
41
|
And then execute:
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
```bash
|
44
|
+
$ bundle
|
45
|
+
```
|
40
46
|
|
41
|
-
<a name="usage"></a>
|
42
47
|
## Usage
|
43
48
|
|
44
49
|
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
50
|
|
46
|
-
<a name="configuration"></a>
|
47
51
|
### Configuration
|
48
52
|
|
49
53
|
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
54
|
|
51
|
-
```
|
55
|
+
```rb
|
52
56
|
Rails.application.configure do
|
53
57
|
config.imgix = {
|
54
58
|
source: "assets.imgix.net"
|
@@ -62,6 +66,7 @@ The following configuration flags will be respected:
|
|
62
66
|
- `source`: a String or Array that specifies the imgix Source address. Should be in the form of `"assets.imgix.net"`.
|
63
67
|
- `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
68
|
- `secure_url_token`: an optional secure URL token found in your dashboard (https://dashboard.imgix.com) used for signing requests
|
69
|
+
- `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
70
|
|
66
71
|
#### Multi-source configuration
|
67
72
|
|
@@ -72,7 +77,7 @@ In addition to the standard configuration flags, the following options can be us
|
|
72
77
|
|
73
78
|
Example:
|
74
79
|
|
75
|
-
```
|
80
|
+
```rb
|
76
81
|
Rails.application.configure do
|
77
82
|
config.imgix = {
|
78
83
|
sources: {
|
@@ -84,8 +89,7 @@ Rails.application.configure do
|
|
84
89
|
end
|
85
90
|
```
|
86
91
|
|
87
|
-
|
88
|
-
### ix_image_tag
|
92
|
+
### `ix_image_tag`
|
89
93
|
|
90
94
|
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
95
|
|
@@ -133,7 +137,7 @@ Will generate URLs using `assets2.imgix.net` source.
|
|
133
137
|
|
134
138
|
We recommend leveraging this to generate powerful helpers within your application like the following:
|
135
139
|
|
136
|
-
```
|
140
|
+
```rb
|
137
141
|
def profile_image_tag(user)
|
138
142
|
ix_image_tag(user.profile_image_url, url_params: { w: 100, h: 200, fit: 'crop' })
|
139
143
|
end
|
@@ -171,8 +175,7 @@ https://assets.imgix.net/image.jpg?ixlib=rails-3.0.2&w=1000&dpr=5&q=
|
|
171
175
|
|
172
176
|
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
177
|
|
174
|
-
|
175
|
-
### ix_picture_tag
|
178
|
+
### `ix_picture_tag`
|
176
179
|
|
177
180
|
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
181
|
|
@@ -243,8 +246,7 @@ To generate a `picture` element on a different source:
|
|
243
246
|
) %>
|
244
247
|
```
|
245
248
|
|
246
|
-
|
247
|
-
### ix_image_url
|
249
|
+
### `ix_image_url`
|
248
250
|
|
249
251
|
The `ix_image_url` helper makes it easy to generate a URL to an image in your Rails app.
|
250
252
|
|
@@ -268,14 +270,13 @@ https://assets2.imgix.net/users/1/avatar.png?w=400&h=300
|
|
268
270
|
|
269
271
|
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
272
|
|
271
|
-
```
|
273
|
+
```rb
|
272
274
|
include Imgix::Rails::UrlHelper
|
273
275
|
|
274
276
|
puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
|
275
277
|
# => https://assets.imgix.net/users/1/avatar.png?w=400&h=300
|
276
278
|
```
|
277
279
|
|
278
|
-
<a name="usage-in-sprockets"></a>
|
279
280
|
#### Usage in Sprockets
|
280
281
|
|
281
282
|
`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 +287,10 @@ puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
|
|
286
287
|
}
|
287
288
|
```
|
288
289
|
|
289
|
-
<a name="using-with-image-uploading-libraries"></a>
|
290
290
|
## Using With Image Uploading Libraries
|
291
291
|
|
292
292
|
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
293
|
|
294
|
-
|
295
|
-
<a name="paperclip-and-carrierwave"></a>
|
296
294
|
### Paperclip and CarrierWave
|
297
295
|
|
298
296
|
Paperclip and CarrierWave can directly provide paths to uploaded images, so we can use them with imgix-rails without a bridge.
|
@@ -301,8 +299,6 @@ Paperclip and CarrierWave can directly provide paths to uploaded images, so we c
|
|
301
299
|
<%= ix_image_tag(@user.avatar.path, { auto: 'format', fit: 'crop', w: 500}) %>
|
302
300
|
```
|
303
301
|
|
304
|
-
|
305
|
-
<a name="refile"></a>
|
306
302
|
### Refile
|
307
303
|
|
308
304
|
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 +329,12 @@ end
|
|
333
329
|
<%= ix_refile_image_tag(@blog_post, :hero_photo, {auto: 'format', fit: 'crop', w: 500}) %>
|
334
330
|
```
|
335
331
|
|
336
|
-
<a name="activestorage"></a>
|
337
332
|
### Active Storage
|
338
333
|
|
339
334
|
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
335
|
|
341
|
-
|
336
|
+
**config/storage.yml**
|
337
|
+
|
342
338
|
```yml
|
343
339
|
service: S3
|
344
340
|
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
@@ -349,15 +345,17 @@ bucket: your_own_bucket
|
|
349
345
|
|
350
346
|
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:
|
351
347
|
|
352
|
-
|
353
|
-
|
348
|
+
**config/environments/production.rb**
|
349
|
+
|
350
|
+
```rb
|
354
351
|
config.active_storage.service = :amazon
|
355
352
|
```
|
356
353
|
|
357
354
|
As you would normally with imgix-rails, configure your application to point to your imgix source:
|
358
355
|
|
359
|
-
|
360
|
-
|
356
|
+
**config/application.rb**
|
357
|
+
|
358
|
+
```rb
|
361
359
|
Rails.application.configure do
|
362
360
|
config.imgix = {
|
363
361
|
source: your_domain,
|
@@ -369,12 +367,12 @@ end
|
|
369
367
|
|
370
368
|
Finally, the two can be used together by passing in the filename of the ActiveStorage blob into the imgix-rails helper function:
|
371
369
|
|
372
|
-
|
370
|
+
**show.html.erb**
|
371
|
+
|
373
372
|
```erb
|
374
373
|
<%= ix_image_tag(@your_model.image.key) %>
|
375
374
|
```
|
376
375
|
|
377
|
-
<a name="upgrade-guides"></a>
|
378
376
|
## Upgrade Guides
|
379
377
|
|
380
378
|
### 3.x to 4.0
|
@@ -391,15 +389,12 @@ For users migrating to version 4.0 or later, it is important that all srcset-rel
|
|
391
389
|
|
392
390
|
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
391
|
|
394
|
-
<a name="development"></a>
|
395
392
|
## Development
|
396
393
|
|
397
394
|
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
395
|
|
399
396
|
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
397
|
|
401
|
-
|
402
|
-
<a name="contributing"></a>
|
403
398
|
## Contributing
|
404
399
|
|
405
400
|
1. Fork it ( https://github.com/[my-github-username]/imgix-rails/fork )
|
data/imgix-rails.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
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", "~>
|
39
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
40
40
|
spec.add_development_dependency "rspec"
|
41
41
|
spec.add_development_dependency "rspec-rails"
|
42
42
|
end
|
data/lib/imgix/rails/version.rb
CHANGED
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: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: imgix
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
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: '
|
55
|
+
version: '12.3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,8 +116,8 @@ licenses:
|
|
116
116
|
metadata:
|
117
117
|
bug_tracker_uri: https://github.com/imgix/imgix-rails/issues
|
118
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.
|
120
|
-
source_code_uri: https://github.com/imgix/imgix-rails/tree/v4.0.
|
119
|
+
documentation_uri: https://www.rubydoc.info/gems/imgix-rails/4.0.1
|
120
|
+
source_code_uri: https://github.com/imgix/imgix-rails/tree/v4.0.1
|
121
121
|
allowed_push_host: https://rubygems.org
|
122
122
|
post_install_message:
|
123
123
|
rdoc_options: []
|
@@ -134,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.6.13
|
137
|
+
rubygems_version: 3.1.2
|
139
138
|
signing_key:
|
140
139
|
specification_version: 4
|
141
140
|
summary: Makes integrating imgix into your Rails app easier. It builds on imgix-rb
|