# SiPhotoUploadComponent documentation

**Kind:** component

**Selector:** `si-photo-upload`

```
import { SiPhotoUploadComponent } from '@siemens/element-ng/photo-upload';
```

A component used to upload, edit, and delete a user's photo. The user can upload a photo either via file browser or a URL to the photo. You can set the source photo with the `sourcePhoto` Data URL input or the `sourcePhotoUrl` URL input. If you already have a cropped image you can set it with the `croppedPhoto` input. Cropping changes are emitted via the `croppedPhotoChange` output.

```
component SiPhotoUploadComponent implements OnChanges, OnDestroy
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [acceptedUploadFormats](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L89-L89>) | `string` | `'.png, .jpg, .jpeg'` | Accepted image formats for the file selection dialog.<br><br>See: [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file\#attr-accept](<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept>) |
| [applyEditText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L207-L207>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.APPLY_PHOTO:Apply` `` | Text for the button applying the edited photo. |
| [autoColor](<https://github.com/siemens/element/blob/main/projects/element-ng/avatar/si-avatar-background-color.directive.ts#L44-L44>) | `boolean` | `false` | Automatically calculates the background color. If set, [color](<index.html#SiPhotoUploadComponent.color>) will be ignored. |
| [cancelEditText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L197-L197>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.CANCEL:Cancel` `` | Text for the button cancelling the editing process. |
| [changePhotoText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L153-L153>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.CHANGE_PHOTO:Change` `` | Text for the button changing the photo. |
| [color](<https://github.com/siemens/element/blob/main/projects/element-ng/avatar/si-avatar-background-color.directive.ts#L36-L36>) | `number` | `undefined` | The desired color index from $si-sys-color-data-categorical-\* color tokens. This can be set to any kind of positive integer that is then mapped to a color index. A better way to set a pseudo-random color is to set [autoColor](<index.html#SiPhotoUploadComponent.autoColor>) to `true`. |
| [croppedPhoto](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L311-L311>) | `string \| undefined` |  | The photo to be displayed and edited (when not readonly). |
| [cropperAspectRatio](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L236-L236>) | `number` | `1` | The width / height ratio (e.g. 1 / 1 for a square, 4 / 3, 16 / 9 ...). |
| [cropperContainWithinAspectRatio](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L253-L253>) | `boolean` | `false` | When set to true, padding will be added around the image to make it fit to the aspect ratio. Be aware that this transformation will cause the loaded image to be a png file with an increased base64 string payload. |
| [cropperFrameAriaLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L163-L165>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.CROPPER_FRAME_LABEL:Crop picture` `` | Cropper frame aria label. |
| [cropperImageFormat](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L229-L229>) | `"png" \| "jpeg"` | `'jpeg'` | Output format of the edited image. |
| [cropperMaintainAspectRatio](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L244-L244>) | `boolean` | `true` | Whether to keep the width and height of the cropped image equal according to the aspectRatio. |
| [cropperMaxHeight](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L286-L286>) | `number` | `0` | The cropper´s height cannot be made bigger than this number of pixels. Default is 0 (disabled). |
| [cropperMaxWidth](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L278-L278>) | `number` | `0` | The cropper´s width cannot be made bigger than this number of pixels. Default is 0 (disabled). |
| [cropperMinHeight](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L270-L270>) | `number` | `50` | The cropper´s height cannot be made smaller than this number of pixels (relative to original image´s size). Will be ignored if `cropperMaintainAspectRatio` is set. (0 = disabled). |
| [cropperMinWidth](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L261-L261>) | `number` | `50` | The cropper´s width cannot be made smaller than this number of pixels (relative to original image´s size). (0 = disabled). |
| [disabledCropping](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L78-L78>) | `boolean` | `false` | Optionally disable image cropping. |
| [maxFileSize](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L96-L96>) | `number` | `2048` | Maximum allowed file size of the uploaded file in kilobytes. |
| [modalDescription](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L222-L222>) | `TranslatableString \| undefined` |  | Text displayed as description of the editing modal. |
| [modalHeader](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L217-L217>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.MODAL_TITLE:Profile picture` `` | Text displayed as header of the editing modal. |
| [photoAltText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L135-L135>) | `TranslatableString` | `''` | Alternative text for the photo. |
| [placeholderAltText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L143-L143>) | `TranslatableString` | `''` | Alternative text for the photo´s placeholder. The value will be used to calculate the background color when `autoColor` is true. |
| [readonly](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L71-L71>) | `boolean` | `false` | Indicate that changing or uploads are disabled. |
| [removePhotoText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L187-L187>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.REMOVE:Remove` `` | Text for the button removing the photo. |
| [roundImage](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L295-L295>) | `boolean` | `true` | Set this to true for a round cropper. Resulting image will still be square, but visually clipped with a border-radius: 50% on the resulting image to show it as round. |
| [sourcePhoto](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L301-L301>) | `string \| undefined` |  | The input photo to be used for cropping. A string in [Data URL](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs>) format with base64 encoding. |
| [sourcePhotoUrl](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L306-L306>) | `string \| undefined` |  | URL to a photo to be used for cropping. |
| [uploadErrorTooBig](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L123-L128>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.ERROR_FILE_SIZE_EXCEEDED:Current file size of {{mb}} MB exceeds file size of max. {{maxSizeMb}} MB` `` | If the uploaded file exceeds the allowed upload size, this error message will be displayed to the user. |
| [uploadErrorWrongType](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L107-L112>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.ERROR_FILE_TYPE:The image file is not valid. Please upload a PNG or JP(E)G.` `` | If the uploaded file is of an unsupported type, this error message will be displayed to the user. |
| [uploadPhotoText](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L175-L177>) | `TranslatableString` | `` $localize`:@@SI_PHOTO_UPLOAD.UPLOAD_PHOTO:Upload picture` `` | Text for the button uploading a photo. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [croppedPhotoChange](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L311-L311>) | `string \| undefined` | The photo to be displayed and edited (when not readonly). |
| [sourcePhotoChange](<https://github.com/siemens/element/blob/main/projects/element-ng/photo-upload/si-photo-upload.component.ts#L301-L301>) | `string \| undefined` | The input photo to be used for cropping. A string in [Data URL](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs>) format with base64 encoding. |

### Types Documentation

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```
