imgix-rails 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -1
- data/README.md +78 -3
- data/imgix-rails.gemspec +1 -1
- data/lib/imgix/rails/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123b72f2be8e8d5a3d5a8170b386e1623d763010
|
4
|
+
data.tar.gz: fdda3f207a947cd64dbef1d1a20f4558b0155deb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 056412199a9166b00ece1946bb78d8399ba8e59bc3079bbe41598cf9774ec0b04d6657e1d0aba4ddd39ca179a70bf229a4f47d03d876d4411e66f69296936644
|
7
|
+
data.tar.gz: 402a42b8784e40243dcee65aaca5a64b531caf629a15efaf78b305cbfb9e3a0f22dd8f40a970eb8fbc436cb29a0c1a9ce56a9a67c936a9e44b4c71fc3097361c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,29 @@
|
|
1
|
-
|
1
|
+
[![imgix logo](https://assets.imgix.net/imgix-logo-web-2014.pdf?page=2&fm=png&w=200&h=200)](https://imgix.com)
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/imgix/imgix-rails.
|
3
|
+
# imgix-rails [![Build Status](https://travis-ci.org/imgix/imgix-rails.svg?branch=master)](https://travis-ci.org/imgix/imgix-rails) [![Slack Status](http://slack.imgix.com/badge.svg)](http://slack.imgix.com)
|
4
4
|
|
5
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
6
|
|
7
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
8
|
|
9
|
-
We recommend using something like [Paperclip](https://github.com/thoughtbot/paperclip), [Carrierwave](https://github.com/carrierwaveuploader/carrierwave), or [s3_direct_upload](https://github.com/waynehoover/s3_direct_upload) to handle uploads
|
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
10
|
|
11
|
+
* [Installation](#installation)
|
12
|
+
* [Usage](#usage)
|
13
|
+
* [Configuration](#configuration)
|
14
|
+
* [ix_image_tag](#ix_image_tag)
|
15
|
+
* [ix_responsive_image_tag](#ix_responsive_image_tag)
|
16
|
+
* [ix_picture_tag](#ix_picture_tag)
|
17
|
+
* [ix_image_url](#ix_image_url)
|
18
|
+
* [Hostname Removal](#hostname-removal)
|
19
|
+
* [Using With Image Uploading Libraries](#using-with-image-uploading-libraries)
|
20
|
+
* [Paperclip](#paperclip)
|
21
|
+
* [Refile](#refile)
|
22
|
+
* [Development](#development)
|
23
|
+
* [Contributing](#contributing)
|
24
|
+
|
25
|
+
|
26
|
+
<a name="installation"></a>
|
11
27
|
## Installation
|
12
28
|
|
13
29
|
Add this line to your application's Gemfile:
|
@@ -20,10 +36,13 @@ And then execute:
|
|
20
36
|
|
21
37
|
$ bundle
|
22
38
|
|
39
|
+
|
40
|
+
<a name="usage"></a>
|
23
41
|
## Usage
|
24
42
|
|
25
43
|
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.
|
26
44
|
|
45
|
+
<a name="configuration"></a>
|
27
46
|
### Configuration
|
28
47
|
|
29
48
|
Before you get started, you will need to define your imgix configuration in your `config/application.rb`, or in an environment-specific configuration file.
|
@@ -43,6 +62,7 @@ The following configuration flags will be respected:
|
|
43
62
|
- `:secure_url_token` a optional secure URL token found in your dashboard (https://webapp.imgix.com) used for signing requests
|
44
63
|
- `:hostnames_to_replace` an Array of hostnames to replace with the value(s) specified by `:source`. This is useful if you store full-qualified S3 URLs in your database, but want to serve images through imgix.
|
45
64
|
|
65
|
+
<a name="ix_image_tag"></a>
|
46
66
|
### ix_image_tag
|
47
67
|
|
48
68
|
The simplest way of working with imgix-rails is to use the `ix_image_tag`, this allows you to pass parameters to imgix to handle things like resizing, cropping, etc.
|
@@ -71,6 +91,7 @@ Then rendering the portrait in your application is very easy:
|
|
71
91
|
<%= profile_image_tag(@user) %>
|
72
92
|
```
|
73
93
|
|
94
|
+
<a name="ix_responsive_image_tag"></a>
|
74
95
|
### ix_responsive_image_tag
|
75
96
|
|
76
97
|
The `ix_responsive_image_tag` helper method makes it easy to bring responsive imagery to your Rails app. We talk a bit about using the `srcset` attribute in an application in the following blog post: [“Responsive Images with `srcset` and imgix.”](http://blog.imgix.com/post/127012184664/responsive-images-with-srcset-imgix)
|
@@ -93,6 +114,7 @@ This will generate the following HTML:
|
|
93
114
|
/>
|
94
115
|
```
|
95
116
|
|
117
|
+
<a name="ix_picture_tag"></a>
|
96
118
|
### ix_picture_tag
|
97
119
|
|
98
120
|
The `ix_picture_tag` helper method makes it easy to generate `<picture>` elements in your Rails app.
|
@@ -115,6 +137,7 @@ Will generate the following HTML:
|
|
115
137
|
</picture>
|
116
138
|
```
|
117
139
|
|
140
|
+
<a name="ix_image_url"></a>
|
118
141
|
### ix_image_url
|
119
142
|
|
120
143
|
The `ix_image_url` helper makes it easy to generate a URL to an image in your Rails app.
|
@@ -171,12 +194,64 @@ Renders:
|
|
171
194
|
<img src="https://my-imgix-source.imgix.net/my-bucket/users/1.png" />
|
172
195
|
```
|
173
196
|
|
197
|
+
|
198
|
+
<a name="using-with-image-uploading-libraries"></a>
|
199
|
+
## Using With Image Uploading Libraries
|
200
|
+
|
201
|
+
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!
|
202
|
+
|
203
|
+
|
204
|
+
<a name="paperclip"></a>
|
205
|
+
### Paperclip
|
206
|
+
|
207
|
+
Paperclip can directly provide paths to uploaded images, so we can use it with imgix-rails without a bridge.
|
208
|
+
|
209
|
+
``` html
|
210
|
+
<%= ix_image_tag(@user.avatar.path, { auto: 'format', fit: 'crop', w: 500}) %>
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
<a name="refile"></a>
|
215
|
+
### Refile
|
216
|
+
|
217
|
+
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.
|
218
|
+
|
219
|
+
``` ruby
|
220
|
+
module ImgixRefileHelper
|
221
|
+
def ix_refile_image_url(obj, key, **opts)
|
222
|
+
path = s3_path(obj, key)
|
223
|
+
path ? ix_image_url(path, opts) : ''
|
224
|
+
end
|
225
|
+
|
226
|
+
def ix_refile_image_tag(obj, key, **opts)
|
227
|
+
path = s3_path(obj, key)
|
228
|
+
path ? ix_image_tag(path, opts) : ''
|
229
|
+
end
|
230
|
+
|
231
|
+
private
|
232
|
+
def s3_path(obj, key)
|
233
|
+
refile_id = obj["#{key}_id"]
|
234
|
+
s3_prefix = obj.send(key).try(:backend).instance_variable_get(:@prefix)
|
235
|
+
|
236
|
+
s3_prefix ? "#{s3_prefix}/#{refile_id}" : nil
|
237
|
+
end
|
238
|
+
end
|
239
|
+
```
|
240
|
+
|
241
|
+
``` html
|
242
|
+
<%= ix_refile_image_tag(@blog_post, :hero_photo, {auto: 'format', fit: 'crop', w: 500}) %>
|
243
|
+
```
|
244
|
+
|
245
|
+
|
246
|
+
<a name="development"></a>
|
174
247
|
## Development
|
175
248
|
|
176
249
|
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.
|
177
250
|
|
178
251
|
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).
|
179
252
|
|
253
|
+
|
254
|
+
<a name="contributing"></a>
|
180
255
|
## Contributing
|
181
256
|
|
182
257
|
1. Fork it ( https://github.com/[my-github-username]/imgix-rails/fork )
|
data/imgix-rails.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_runtime_dependency "imgix", "~> 1.
|
30
|
+
spec.add_runtime_dependency "imgix", "~> 1.1", ">= 1.1.0"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.9"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
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: 1.
|
4
|
+
version: 1.1.0
|
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: 2016-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: imgix
|
@@ -17,20 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.1'
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.1.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '1.
|
30
|
+
version: '1.1'
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.1.0
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: bundler
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|