You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Configuring an image column on portals (preview)
2
+
title: Configure an image column on portals (preview)
3
3
description: Learn how to configure an image column on portals.
4
4
author: nageshbhat-msft
5
-
6
5
ms.topic: conceptual
7
6
ms.custom:
8
-
ms.date: 04/28/2022
7
+
ms.date: 05/04/2022
9
8
ms.subservice: portals
10
9
ms.author: nabha
11
10
ms.reviewer: ndoelman
12
11
contributors:
13
12
- ProfessorKendrick
14
13
- nickdoelman
15
14
---
16
-
# Configuring an image column on portals (preview)
17
15
18
-
>[!NOTE]
19
-
> - This is a preview feature. Preview features aren't meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.
You can configure image column fields on basic and advanced forms to upload, view, modify, and delete images. Image column allows you to store an image file up to the specified maximum size in Dataverse table columns. The thumbnail images can be seen in the web application when viewing the form data.
20
+
An image column stores an image file in a column in a Dataverse table. Add an image column to a form to upload, view, modify, and delete images. The form shows a thumbnail of the image if one is available.
22
21
23
-
:::image type="content" source="media/image-column/edit-image.png" alt-text="Navigating the edit image functionality.":::
22
+
## Prerequisites
24
23
25
-
## Enable image control on forms
24
+
-**If you configure your site using the Portal Management app:** While the feature is in preview, you'll need to set the value of the site setting **Control/EnableImagePreview** to **true** to add image controls to a form.
26
25
27
-
You must configure site settings **Control/EnableImagePreview** and set its value to **true** to enable **Image** controls on the form. You don't require to make any configuration to make imagecolumn with Liquid code and Web API.
26
+
:::image type="content" source="media/image-column/upload-image-preview.png" alt-text="Screenshot of the Control/EnableImagePreview site setting.":::
Developers can design the website by using Liquid code to retrieve the records from Dataverse tables. Image column values can be fetched while data being queried by using fetchXML and entity view
51
+
For example, if your portal is located at https://contososite.powerappsportals.com, your code will look like this:
You can design a website using [Liquid code](../liquid/liquid-overview.md) to retrieve records from Dataverse tables. Use fetchXML and the **Entity** view to fetch image column values, like this:
61
+
62
+
```xml
55
63
{% for item in tables.results.entities %}
56
64
{{ item.columnname.Type }}
57
65
{{ item.columnname.Size }}
58
66
{{ item.columnname.Url }}
59
67
{{ item.columnname.Value }}
60
68
{% endfor %}
61
69
```
62
-
|||
63
-
|-------|------------------------------|
64
-
| Type | Mime type of the image |
65
-
| Size | Image size in bytes |
66
-
| Value | Image value in base64 string |
67
-
| Url | Image url |
68
70
69
-
### Example: Retrieve default contact image
71
+
where:
72
+
73
+
-**Type** is the mime type of the image
74
+
75
+
-**Size** is the image size in bytes
76
+
77
+
-**Value** is the image value as a base64 string
78
+
79
+
-**Url** is the image URL
80
+
81
+
### Example: Retrieve a default contact image
70
82
71
83
> [!NOTE]
72
-
> Make sure you have configured the appropriate table permissions on the contact table to read the record.
84
+
> Make sure you have [set the appropriate permissions](#create-a-table-permission) on the contact table to read the record.
The [portals Web API](../web-api-overview.md) can be used to perform, create, read, update, and delete operations on image columns across Dataverse tables.
109
+
The [portals Web API](../web-api-overview.md) can be used to create, read, update, and delete images in image columns across Dataverse tables.
99
110
100
-
##Retrieving image data
111
+
### Retrieve image data
101
112
102
-
To download thumbnail image data, use following APIs
113
+
To download thumbnail image data, use the following API call:
103
114
104
-
```
115
+
```html
105
116
GET /_api/<entity-type>(id)/<image-attribute-name>/$value
106
117
```
107
118
108
-
Image data transfers from the web service endpoints are limited to a maximum of 16-MB data in a single service call.
119
+
Image data transferred from the web service endpoints is limited to a maximum of 16 MB in a single service call.
109
120
110
-
### Example: Thumbnail download
121
+
####Example: Download a thumbnail
111
122
112
-
#### Request
123
+
In the following example, we'll use a GET call to download a thumbnail if it exists.
113
124
114
-
**HTTP**
115
-
```
125
+
HTTP request:
126
+
127
+
```html
116
128
GET [Portal Url]/_api/accounts(62d53214-9dfa-eb11-94ee-0022482230a8)/entityimage/$value
117
129
118
130
Headers:
119
131
Content-Type: application/octet-stream
120
-
```
132
+
```
121
133
122
-
#### Response
134
+
HTTP response:
123
135
124
-
**HTTP**
125
-
```
136
+
```html
126
137
204 No Content
127
138
128
139
Body:
129
140
Byte[ ]
130
141
```
131
142
132
-
## Upload image data
143
+
In this example, the thumbnail doesn't exist and so no image is returned. If a thumbnail did exist, the response would return a byte array with values.
133
144
134
-
To upload the images, set the value of the image column to a byte array that contains the content of the image file:
145
+
### Upload image data
135
146
136
-
```
147
+
To upload an image, set the value of the image column to a byte array that contains the content of the image file:
148
+
149
+
```html
137
150
PUT or PATCH /_api<entity-type>(id)/<image-attribute-name>
138
151
```
139
152
140
-
### Example: image upload
153
+
####Example: Upload an image
141
154
142
-
#### Request
155
+
HTTP request:
143
156
144
-
```
157
+
```html
145
158
PUT [Portal Url]/_api/accounts(62d53214-9dfa-eb11-94ee-0022482230a8)/entityimage
146
159
147
160
Headers:
@@ -151,40 +164,64 @@ To upload the images, set the value of the image column to a byte array that con
151
164
Byte [ ]
152
165
```
153
166
154
-
##Configure Profile Image
167
+
### Upload profile images
155
168
156
-
Profile picture serve as a visual of the person, so that he can be recognized visually. Now authenticated portal users can upload their image in the profile section. These images are saved in **Entity Image** column of the corresponding contact record in Dataverse. Users can upload image size up to 10 MB. A portal maker can allow uploading profile picture for the authenticated users by updating the site setting.
169
+
Authenticated portal users can upload their picture in the profile section of the portal. The image is saved in the **Entity Image** column of the corresponding contact record in Dataverse. Users can upload images up to 10 MB.
170
+
171
+
#### Create site settings
172
+
173
+
First, you must create a site setting to allow authenticated users to upload a profile picture:
157
174
158
175
1. Sign in to [Power Apps](https://make.powerapps.com/).
159
-
1. Ensure that you're in the appropriate environment where your portal exists.
160
-
1. Select **Apps** in the left navigation pane, and locate the **Portal Management** model-driven app.
161
-
1. Select to open the **Portal Management** app, and then go to **Site Settings** in the left navigation pane.
162
176
163
-
:::image type="content" source="media/image-column/site-settings.png" alt-text="The site settings options within the Portal management app.":::
177
+
1. Select the environment that contains your portal.
164
178
165
-
1.Create or Update setting, **Profile/ShowImage**, and set its value to **true**.
179
+
1.In the left pane, select **Apps**, and then open the **Portal Management** app.
166
180
167
-
> [!NOTE]
168
-
> The following steps are only required during the preview period.
181
+
:::image type="content" source="media/image-column/add-settings-site.png" alt-text="Screenshot of the Apps list, with the Portal Management app highlighted.":::
182
+
183
+
1. In the left pane, select **Site Settings**.
184
+
185
+
1. Create a setting called **Profile/ShowImage**, and set its value to **true**. (If the setting exists, set its value to **true**.)
186
+
187
+
:::image type="content" source="media/image-column/add-setting-showimage.png" alt-text="Screenshot of the Profile/ShowImage site setting.":::
169
188
170
-
1. Create or Update setting, **Webapi/contact/enabled**, and set its value to **true**.
171
-
1. Create or Update setting, **Webapi/contact/fields**, and set its value to **entityimage**.
189
+
While the feature is in preview, also add or update the following site settings:
172
190
173
-
### Create a table permission to allow authenticated user to upload profile picture to his contact records.
191
+
- Set **Webapi/contact/enabled**to **true**.
174
192
175
-
1. Select **Table Permissions** in the left navigation pane.
176
-
1. Select **New**.
193
+
- Set **Webapi/contact/fields** to **entityimage**.
177
194
178
-
:::image type="content" source="media/image-column/new.png" alt-text="Select new from table permissions.":::
195
+
:::image type="content" source="media/image-column/add-settings-webapi.png" alt-text="Screenshot of the webapi site settings.":::
Next, you must create a table permission to allow authenticated users to upload a profile picture:
200
+
201
+
1. In the left pane, under **Security**, select **Table Permissions**, and then select **New**.
202
+
203
+
:::image type="content" source="media/image-column/add-table-permission.png" alt-text="Screenshot of the Active Table Permissions view, with New highlighted.":::
204
+
205
+
1. Set the permission details as follows:
206
+
207
+
- Enter a meaningful name for the permission. In our example, we've entered "Contact Profile Update Permission."
208
+
209
+
- In the **Table Name** list, select **Contact (contact)**.
210
+
211
+
- In **Website**, search for and select the name of your portal.
212
+
213
+
- In the **Access Type** list, select **Self**.
214
+
215
+
- Under **Privileges**, select **Read**, **Write**, **Append**, and **Append To**.
216
+
217
+
:::image type="content" source="media/image-column/add-table-permission-details.png" alt-text="Screenshot of the details of a new table permission called Contact Profile Update Permission.":::
183
218
184
219
1. Select **Save & Close**.
185
-
1. Select and open **Contact Profile Update Permission**.
186
-
1. Scroll down to the **Web Roles** section, and then select **Add Existing Web Role**.
187
-
1. Search for **Authenticated Users**, and then select **Add**:
1. In the **Active Table Permissions** view, select **Contact Profile Update Permission** (or whatever you named your new permission).
222
+
223
+
1. In the **Web Roles** section, select **Add Existing Web Role**.
224
+
225
+
1. Search for and select **Authenticated Users**, and then select **Add**.
190
226
227
+
:::image type="content" source="media/image-column/add-auth-users-web-role.png" alt-text="Screenshot that shows Authenticated Users selected as a web role.":::
0 commit comments