# Javascript: ImageCollection.getItem Method

> Gets the image selected by the user or the image with the specified identifier.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: ImageCollection.getItem Method
- **400 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/getitem-method/llms-full.txt

---

### Description

Gets the image selected by the user or the image with the specified identifier.

### Syntax

```javascript
<void> ImageCollection.getItem(<RequestImageCallback> callback, [<ErrorCallback> errorCallback], [<number> id])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the requested image or null if there is no image at the current input position / with the specified identifier. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. The image's identifier. |

### Examples

The following example demonstrates `ImageCollection.getItem` in a practical document-editing workflow. It gets the image selected by the user or the image with the specified identifier.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.images.getItem(
    function(image) {
        if (!image) {
            console.warn("No image was returned.");
            return;
        }
        
        console.log("get item result:", image);
    },
    onTxError,
    25
);
```

---

## Nearby

- **Previous:** [Javascript: ImageCollection.addInline Method](https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/addinline-method/llms-full.txt)
- **Next:** [Javascript: ImageCollection.getItemByName Method](https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/getitembyname-method/llms-full.txt)
