Class: BulmaPhlex::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/bulma_phlex/image.rb

Overview

Renders a Bulma image component.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Image

Returns a new instance of Image.



19
20
21
22
23
24
25
26
27
# File 'lib/bulma_phlex/image.rb', line 19

def initialize(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes)
  @src = src
  @alt = alt
  @rounded = rounded
  @size = size
  @ratio = ratio
  @img_attributes = img_attributes
  @html_attributes = html_attributes
end

Class Method Details

.new(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Object

Parameters

  • src: — The image source URL (required)
  • alt: — The image alt text (optional)
  • rounded: — Whether to apply the is-rounded class (optional, default: false)
  • size: — The image size (optional, e.g., 64 for is-64x64)
  • ratio: — The image ratio (optional, e.g., "1by1", "4by3", "16by9")
  • img_attributes: — Additional HTML attributes for the img element (optional)
  • **html_attributes — Additional HTML attributes for the figure element (optional)


15
16
17
# File 'lib/bulma_phlex/image.rb', line 15

def self.new(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes)
  super
end

Instance Method Details

#view_templateObject



29
30
31
32
33
# File 'lib/bulma_phlex/image.rb', line 29

def view_template
  figure(**mix({ class: figure_classes }, @html_attributes)) do
    img(**mix({ src: @src, alt: @alt, class: img_classes }, @img_attributes))
  end
end