module ActiveStorage::Blob::Representable
def variant(transformations)
transform the blob. To determine whether a blob is variable, call
Raises ActiveStorage::InvariableError if the variant processor cannot
can then produce on-demand.
This will create a URL for that specific blob with that specific variant, which the ActiveStorage::RepresentationsController
<%= image_tag Current.user.avatar.variant(resize_to_limit: [100, 100]) %>
specific variant that can be created by a controller on-demand. Like so:
Frequently, though, you don't actually want to transform the variant right away. But rather simply refer to a
Then it'll upload said variant to the service according to a derivative key of the blob and the transformations.
This will create and process a variant of the avatar blob that's constrained to a height and width of 100px.
avatar.variant(resize_to_limit: [100, 100]).processed.url
This is only relevant for image files, and it allows any image to be transformed for size, colors, and the like. Example:
Returns an ActiveStorage::Variant or ActiveStorage::VariantWithRecord instance with the set of +transformations+ provided.
def variant(transformations) if variable? variant_class.new(self, ActiveStorage::Variation.wrap(transformations).default_to(default_variant_transformations)) else raise ActiveStorage::InvariableError end end