# Img

The HTML img tag, implemented in Ruby.

## Parameters

The image takes a mandatory path argument and can take 4 optional configuration params.

#### path

Expects a string with the source to the image.

By default it looks for the image in the assets/images folder and uses the standard Rails asset pipeline unless given an absolute path.

See examples below.

#### alt (optional)

Expects a string with the alt text the image should have.

#### height (optional)

Expects an integer with the height of the image in px.

#### usemap (optional)

Expects a string to specify the image as a client-side image-map.

#### width (optional)

Expects an integer with the width of the image in px.

## Examples

### Example 1: Use Sprockets (Rails asset pipeline) implicitly

If your image is located here: `app/assets/images/some_image.png`

```ruby
img path: "some_image.png"
```

### Example 2: Use Sprockets (Rails asset pipeline) explicitly

If your image is located here: `app/assets/images/some_image.png`

```ruby
img path: image_url('some_image.png')
```

### Example 3: Use Webpacker explicitly

If something like below is configured in your pack.js and your image is located here: `app/javascript/images/some_image.png`

`app/javascript/packs/application.js`

```javascript
const images = require.context('../images', true)
const imagePath = (name) => images(name, true)
```

```ruby
img path: asset_pack_url('media/images/some_image.png')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.matestack.io/matestack-ui-core/1.5.0/components-api/core-components/img.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
