0.02
No commit activity in last 3 years
No release in over 3 years
thumbor_rails is a client for the thumbor imaging service (http://github.com/globocom/thumbor) for Ruby and Rails projects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 4.0
>= 1.2.1
 Project Readme

Thumbor Rails Build Status

https://github.com/rafaelcaricio/thumbor_rails

DESCRIPTION

thumbor_rails is a client to make easier to use the thumbor imaging service (http://github.com/globocom/thumbor) in Ruby and Rails projects.

Installation

You can use this gem by putting the following inside your Gemfile:

gem "thumbor_rails", "1.2.0"

Now generate the thumbor basic client configuration:

rails g thumbor_rails:install

It will generate the basic configuration in config/initializers/thumbor_rails.rb, which has the following configuration options available:

  • server_url. Required. The location of your Thumbor server. If server_url contains %d, it will be interpolated to 0-3, just like asset_host for Rails.
  • sercurity_key. Optional. This must match your Thumbor server's security key.
  • force_no_protocol_in_source_url. Optional, defaults to false. If true, the protocol is removed from any image source passed into thumbor_url. This may be done for aesthetic reasons, or due to certain CDN/server configurations.

Usage

There are two basic helpers you can use in your views:

thumbor_url
thumbor_image_tag

thumbor_url

The thumbor_url helper allows you to to generate a thumbor url, a simple use is:

<%= thumbor_url "http://example.com/awesome_image.jpg" %>

Of course, you can pass various parameters to thumbor as described in the ruby-thumbor gem. An exemple would be:

<%= thumbor_url "http://example.com/awesome_image.jpg", width: 200, height: 300 %>

thumbor_image_tag

The thumbor_image_tag helper allows you to simplify the usage when creating a simple image tag in your views. It returns a complete image tag with the generated thumbor url in the src attribute of the img tag. Example:

<%= thumbor_image_tag "http://myimage.jpg", unsafe: true, width: 100, height: 100 %>

Will result in something like:

<img alt="Myimage" src="http://thumbor.example.com/unsafe/100x100/http://myimage.jpg" />

Disabling Thumbor

Setting the DISABLE_THUMBOR environment variable will disable thumbor_image_tag and thumbor_url and they will return the original url instead. This is in case you don't want to use Thumbor locally or want to disable it temporarily.

Maintainers

and contributors.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Extras

If you do not have yet an instance of thumbor for you. You can get one for free up and running in the OpenShift Cloud.