class Line::Message::Builder::Flex::Image
Represents an “image” component in a LINE Flex Message.
Images are specified by a URL and can be included in various parts of a Flex Message, such as a box, a bubble’s hero section, etc. They offer several properties to control their appearance, including size, aspect_ratio, and aspect_mode. An image can also have an action to make it tappable.
Example
Line::Message::Builder.with do
flex alt_text: "Image Example" do
bubble do
body do
image "https://example.com/image.png",
aspect_ratio: "16:9",
aspect_mode: :cover,
size: :full
end
end
end
end
end
See also:
-
Actionablefor making the image tappable -
Position::Horizontalforalignproperty -
Position::Verticalforgravityproperty -
Position::Marginformarginproperty -
Position::Offsetfor offset properties -
Size::Flexforflexsizing property -
Size::Imageforsize,aspect_ratio, andaspect_modeproperties
Attributes
The URL of the image (must be HTTPS). This is a required attribute.
Public Class Methods
Source
# File lib/line/message/builder/flex/image.rb, line 96 def initialize(url, context: nil, **options, &) @url = url # The image URL is mandatory. super(context: context, **options, &) # Sets options and evals block (for action). end
Initializes a new Flex Message Image component.
- url
-
The HTTPS URL of the image (required)
- context
-
An optional context for the builder (default:
nil) - options
-
A hash of options to set instance variables (e.g.,
:aspect_ratio,:aspect_mode,:size, and options from included modules) - block
-
An optional block, typically used to define an action for the image
Raises RequiredError if url is nil when building the message.
Example
image = Line::Message::Builder::Flex::Image.new( "https://example.com/image.png", aspect_ratio: "16:9", aspect_mode: :cover )
Line::Message::Builder::Base::new