Skip to content

Commit 023c227

Browse files
authored
Live publish
2 parents 1e347e1 + 4cb9442 commit 023c227

12 files changed

+111
-74
lines changed
Lines changed: 111 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,89 @@
11
---
2-
title: Configuring an image column on portals (preview)
2+
title: Configure an image column on portals (preview)
33
description: Learn how to configure an image column on portals.
44
author: nageshbhat-msft
5-
65
ms.topic: conceptual
76
ms.custom:
8-
ms.date: 04/28/2022
7+
ms.date: 05/04/2022
98
ms.subservice: portals
109
ms.author: nabha
1110
ms.reviewer: ndoelman
1211
contributors:
1312
- ProfessorKendrick
1413
- nickdoelman
1514
---
16-
# Configuring an image column on portals (preview)
1715

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.
16+
# Configure an image column on portals (preview)
17+
18+
[!INCLUDE [cc-preview-features-definition](../../../includes/cc-preview-features-definition.md)]
2019

21-
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.
2221

23-
:::image type="content" source="media/image-column/edit-image.png" alt-text="Navigating the edit image functionality.":::
22+
## Prerequisites
2423

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.
2625

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 image column 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.":::
2827

29-
:::image type="content" source="media/image-column/image-preview.png" alt-text="Enable image preview.":::
28+
>[!IMPORTANT]
29+
> This site setting is only required during the preview period.
3030
31-
>[!IMPORTANT]
32-
> This site setting is only required during the preview period.
31+
- **If you use [Liquid code](#liquid) or the [Web API](#web-api):** There's nothing more you need to do to add image controls to a form.
3332

3433
## Image URL
3534

36-
An absolute URL to display the entity image in a client
35+
The image URL indicates the full URL of where the image is stored. This can be used for development and troubleshooting.
3736

38-
The URL is composed in following way
37+
An image URL takes the following form:
3938

40-
```{0}/Image/download.aspx?entity={1}&attribute={2}&id={3}```
39+
```{0}/Image/download.aspx?entity={1}&attribute={2}&id={3}```
4140

42-
0 – Portal url
41+
where:
4342

44-
1 – entity logical name
43+
- **{0}** is the portal URL
4544

46-
2 – column logical name
45+
- **{1}** is the logical name of the entity
4746

48-
3 – image ID
47+
- **{2}** is the logical name of the column
4948

50-
## Liquid
49+
- **{3}** is the image ID
5150

52-
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:
5352

53+
```
54+
https://contososite.powerappsportals.com/Image/download.aspx?entity=contact&attribute=entityimage&id=cb059a4a-b1a6-ec11-9840-00224829604e
5455
```
56+
57+
58+
## Liquid
59+
60+
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
5563
{% for item in tables.results.entities %}
5664
{{ item.columnname.Type }}
5765
{{ item.columnname.Size }}
5866
{{ item.columnname.Url }}
5967
{{ item.columnname.Value }}
6068
{% endfor %}
6169
```
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 |
6870

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
7082

7183
> [!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.
7385
74-
```
86+
```xml
7587
{% fetchxml contacts %}
7688
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
7789
<entity name="contact">
@@ -84,64 +96,65 @@ Developers can design the website by using Liquid code to retrieve the records f
8496
{% for item in contacts.results.entities %}
8597
{
8698
"Full Name":"{{ item.fullname }}"
87-
"Entity Image Url":"{{ item.entityimage.Url}}",
88-
"Entity Image Size":"{{ item.entityimage.Size}}",
8999
"Entity Image Type":"{{ item.entityimage.Type}}",
100+
"Entity Image Size":"{{ item.entityimage.Size}}",
101+
"Entity Image Url":"{{ item.entityimage.Url}}",
90102
"Entity Image Value":"{{ item.entityimage.Value}}"
91103
}
92104
{% endfor %}
93105
```
94106

95-
96107
## Web API
97108

98-
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.
99110

100-
## Retrieving image data
111+
### Retrieve image data
101112

102-
To download thumbnail image data, use following APIs
113+
To download thumbnail image data, use the following API call:
103114

104-
```
115+
```html
105116
GET /_api/<entity-type>(id)/<image-attribute-name>/$value
106117
```
107118

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.
109120

110-
### Example: Thumbnail download
121+
#### Example: Download a thumbnail
111122

112-
#### Request
123+
In the following example, we'll use a GET call to download a thumbnail if it exists.
113124

114-
**HTTP**
115-
```
125+
HTTP request:
126+
127+
```html
116128
GET [Portal Url]/_api/accounts(62d53214-9dfa-eb11-94ee-0022482230a8)/entityimage/$value
117129

118130
Headers:
119131
Content-Type: application/octet-stream
120-
```
132+
```
121133

122-
#### Response
134+
HTTP response:
123135

124-
**HTTP**
125-
```
136+
```html
126137
204 No Content
127138

128139
Body:
129140
Byte[ ]
130141
```
131142

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.
133144

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
135146

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
137150
PUT or PATCH /_api<entity-type>(id)/<image-attribute-name>
138151
```
139152

140-
### Example: image upload
153+
#### Example: Upload an image
141154

142-
#### Request
155+
HTTP request:
143156

144-
```
157+
```html
145158
PUT [Portal Url]/_api/accounts(62d53214-9dfa-eb11-94ee-0022482230a8)/entityimage
146159

147160
Headers:
@@ -151,40 +164,64 @@ To upload the images, set the value of the image column to a byte array that con
151164
Byte [ ]
152165
```
153166

154-
## Configure Profile Image
167+
### Upload profile images
155168

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:
157174

158175
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.
162176

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.
164178

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.
166180

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.":::
169188

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:
172190

173-
### Create a table permission to allow authenticated user to upload profile picture to his contact records.
191+
- Set **Webapi/contact/enabled** to **true**.
174192

175-
1. Select **Table Permissions** in the left navigation pane.
176-
1. Select **New**.
193+
- Set **Webapi/contact/fields** to **entityimage**.
177194

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.":::
179196

180-
1. Update the details as provided below.
197+
#### Create a table permission
181198

182-
:::image type="content" source="media/image-column/update-details.png" alt-text="Update details.":::
199+
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.":::
183218

184219
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**:
188220

189-
:::image type="content" source="media/image-column/add.png" alt-text="Add authenticated users":::
221+
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**.
190226

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.":::
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)