instance method variant

Ruby on Rails 8.1.2

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

variant(transformations)

Returns an ActiveStorage::Variant or ActiveStorage::VariantWithRecord instance for the attachment with the set of transformations provided. Example:

avatar.variant(resize_to_limit: [100, 100]).processed.url

or if you are using pre-defined variants:

avatar.variant(:thumb).processed.url

See ActiveStorage::Blob::Representable#variant for more information.

Raises an ArgumentError if transformations is a Symbol which is an unknown pre-defined variant of the attachment.

Parameters

transformations req
Source
# File activestorage/app/models/active_storage/attachment.rb, line 82
  def variant(transformations)
    transformations = transformations_by_name(transformations)
    blob.variant(transformations)
  end

Defined in activestorage/app/models/active_storage/attachment.rb line 82 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Attachment

Type at least 2 characters to search.

↑↓ navigate · open · esc close