0.0
No release in over 3 years
Low commit activity in last 3 years
Make ActiveStorage's variant named and configurable
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

NamedVariant [DEPRECATED]

This gem is deprecated due to rails/rails#39135

Gem Version Build Status

Make ActiveStorage's variant named and configurable.

Usual process is

class User < ActiveRecord::Base
  has_one_attached :avatar
end

and view.

= image_tag(user.avatar.variant(resize: "100x100", monochrome: true, flip: "-90").processed)

It's annoying, and sometimes not DRY. NamedVarient gives a solution.

class User < ActiveRecord::Base
  has_one_attached :avatar

  variant_name :monochrome, resize: "100x100", monochrome: true, flip: "-90"
end
= image_tag(user.avatar.variant(:monochrome).processed)
# only user's attachment can call `monochrome` variant.

Installation

gem 'named_variant'

And then execute:

$ bundle

Todo

  • scoped variant name support
  • config file support

License

The gem is available as open source under the terms of the MIT License.