Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

CGI::HtmlExtension#image_button

image_button(src = "", name = nil, alt = nil)

Generate an Image Button Input element as a string.

src is the URL of the image to use for the button. name is the input name. alt is the alternative text for the image.

Alternatively, the attributes can be specified as a hash.

Example
image_button("url")
  # <INPUT TYPE="image" SRC="url">

image_button("url", "name", "string")
  # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">

image_button("SRC" => "url", "ALT" => "string")
  # <INPUT TYPE="image" SRC="url" ALT="string">
See also #html #img #hidden #multipart_form also in 3.4 · 3.3 · 3.1 · 3.0