CellImage

Represents an image value in a cell. To add an image to a cell, you must create a new image value
for the image using `https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#newCellImage()` and `https://developers.google.com/apps-script/reference/spreadsheet/cell-image-builder`. Then you can use `https://developers.google.com/apps-script/reference/spreadsheet/range#setValue(Object)` or `https://developers.google.com/apps-script/reference/spreadsheet/range#setValues(Object)` to
add the image value to the cell.

### Properties

| Property | Type | Description |
|---|---|---|
| `valueType` | `https://developers.google.com/apps-script/reference/spreadsheet/value-type` | The value type of the cell image, which is `ValueType.IMAGE`. |

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/spreadsheet/cell-image#getAltTextDescription()` | `String` | Returns the alt text description for this image. |
| `https://developers.google.com/apps-script/reference/spreadsheet/cell-image#getAltTextTitle()` | `String` | Returns the alt text title for this image. |
| `https://developers.google.com/apps-script/reference/spreadsheet/cell-image#getContentUrl()` | `String` | Returns a Google-hosted URL to the image. |
| `https://developers.google.com/apps-script/reference/spreadsheet/cell-image#toBuilder()` | `https://developers.google.com/apps-script/reference/spreadsheet/cell-image-builder` | Creates a cell image builder based on the current image properties. |

### Deprecated methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/spreadsheet/cell-image#getUrl()` | `String` | Gets the image's source URL. |

## Detailed documentation

### `getAltTextDescription()`

Returns the alt text description for this image.

#### Return


`String` --- The alt text description.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getAltTextTitle()`

Returns the alt text title for this image.

#### Return


`String` --- The alt text title.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getContentUrl()`

Returns a Google-hosted URL to the image. This URL is tagged with the account of the requester,
so anyone with the URL effectively accesses the image as the original requester. Access to the
image might be lost if the spreadsheet's sharing settings change. The returned URL expires
after a short period of time.

```javascript
const range = SpreadsheetApp.getActiveSpreadsheet().getRange("Sheet1!A1");
const value = range.getValue();
if (value.valueType == SpreadsheetApp.ValueType.IMAGE) {
  console.log(value.getContentUrl());
}
```

#### Return


`String` --- The Google-hosted URL of the image.

*** ** * ** ***

### `toBuilder()`

Creates a cell image builder based on the current image properties. Use `https://developers.google.com/apps-script/reference/spreadsheet/cell-image-builder#setSourceUrl(String)` to set the source URL of the new image. Then you can add it to a
cell using `https://developers.google.com/apps-script/reference/spreadsheet/range#setValue(Object)` or `https://developers.google.com/apps-script/reference/spreadsheet/range#setValues(Object)`.

```javascript
const ss = SpreadsheetApp.getActiveSpreadsheet();
const range = ss.getRange("Sheet1!A1");
const value = range.getValue();
if (value.valueType == SpreadsheetApp.ValueType.IMAGE) {
  const newImage =
      value.toBuilder()
          .setSourceUrl(
              'https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png',
              )
          .build();
  const newRange = ss.getRange("Sheet1!A2");
  newRange.setValue(newImage);
}
```

#### Return


`https://developers.google.com/apps-script/reference/spreadsheet/cell-image-builder` --- A builder that creates an image value type based on the given image properties.

## Deprecated methods

### `getUrl()`


**Deprecated.** For most newly inserted images, the source URL is unavailable.

Gets the image's source URL. Returns an empty string if the URL is unavailable. For most newly
inserted images, the source URL is unavailable regardless how the image is inserted.

#### Return


`String` --- The image's source URL if available; returns an empty string otherwise.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`