Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
CGI::HtmlExtension#image_button
image_button(src = "", name = nil, alt = nil)
lib/cgi/html.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/cgi/html.rb, line 448
def image_button(src = "", name = nil, alt = nil)
attributes = if src.kind_of?(String)
{ "TYPE" => "image", "SRC" => src, "NAME" => name,
"ALT" => alt }
else
src["TYPE"] = "image"
src["SRC"] ||= ""
src
end
input(attributes)
end
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">