rails image tag
<%= image_tag("image.jpg", alt: "Description", class: "img-class", size: "100x100", data: { attribute1: 'value1', attribute2: 'value2' }) %>
Explanation of each step:
<%=
: Embeds Ruby code into the HTML template.image_tag("image.jpg", ...)
: Generates an HTML image tag with the specified image source and additional attributes."image.jpg"
: The source of the image file.alt: "Description"
: Specifies the alternative text for the image, used for accessibility.class: "img-class"
: Assigns a CSS class to the image for styling purposes.size: "100x100"
: Sets the dimensions of the image (width x height).data: { attribute1: 'value1', attribute2: 'value2' }
: Adds custom data attributes to the image tag, which can be accessed using JavaScript.%>
: Closes the Ruby code block. ```