Skip to content

Commit

Permalink
Add pre-defined variant examples
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakmahakale committed Oct 10, 2022
1 parent 3258979 commit 0d1633c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions activestorage/app/models/active_storage/attachment.rb
Expand Up @@ -49,6 +49,14 @@ def purge_later

# 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
Expand All @@ -60,6 +68,14 @@ def variant(transformations)

# Returns an ActiveStorage::Preview instance for the attachment with the set
# of +transformations+ provided.
# Example:
#
# video.preview(resize_to_limit: [100, 100]).processed.url
#
# or if you are using pre-defined variants:
#
# video.preview(:thumb).processed.url
#
# See ActiveStorage::Blob::Representable#preview for more information.
#
# Raises an +ArgumentError+ if +transformations+ is a +Symbol+ which is an
Expand All @@ -71,6 +87,14 @@ def preview(transformations)

# Returns an ActiveStorage::Preview or an ActiveStorage::Variant for the
# attachment with set of +transformations+ provided.
# Example:
#
# avatar.representation(resize_to_limit: [100, 100]).processed.url
#
# or if you are using pre-defined variants:
#
# avatar.representation(:thumb).processed.url
#
# See ActiveStorage::Blob::Representable#representation for more information.
#
# Raises an +ArgumentError+ if +transformations+ is a +Symbol+ which is an
Expand Down

0 comments on commit 0d1633c

Please sign in to comment.