Skip to content

Commit c23ccc0

Browse files
Merge branch 'main' into patch-3
2 parents 7cb9d84 + 73ac4ee commit c23ccc0

File tree

9 files changed

+213
-3
lines changed

9 files changed

+213
-3
lines changed

docs/declarative-customization/formatting-syntax-reference.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Formatting syntax reference
33
description: Formatting syntax reference
4-
ms.date: 02/09/2022
4+
ms.date: 02/22/2022
55
ms.localizationpriority: high
66
---
77

@@ -19,9 +19,22 @@ Specifies the type of element to create. Valid elements include:
1919
- path
2020
- button
2121
- p
22+
- [filepreview](#filepreview)
2223

2324
Any other value will result in an error.
2425

26+
### filepreview
27+
28+
Use the special elmType `filepreview` in conjunction with the `src` attribute set to [`@thumbnail.<Size>`](#thumbnails) to view thumbnails for files in your document libary.
29+
If the thumbnail loads successfully, a small [brand type icon](https://developer.microsoft.com/en-us/fluentui#/styles/web/office-brand-icons) is visible on the bottom left. If the thumbanil fails to load (or if the file type doesn't support thumbnails), a [file type icon](https://developer.microsoft.com/en-us/fluentui#/styles/web/file-type-icons) is shown instead.
30+
31+
```json
32+
"elmType": "filepreview",
33+
"attributes": {
34+
"src": "@thumbnail.medium"
35+
}
36+
```
37+
2538
## txtContent
2639

2740
An optional property that specifies the text content of the element specified by `elmType`. The value of this property can either be a string (including special strings) or an Expression object.
@@ -384,6 +397,30 @@ Adds the field editor for the referenced column.
384397
"txtContent": "[$FieldName]"
385398
}
386399
```
400+
## filePreviewProps
401+
402+
An optional property, that allows overriding the default styles of file type icon and brand type icon in `filepreview` elmType.
403+
404+
- `fileTypeIconClass` and `brandTypeIconClass` can be used to provide CSS class names to the file type icon and the brand type icon elements respectively.
405+
406+
- `fileTypeIconStyle` and `brandTypeIconStyle` can be used to provide [styles](#style) to the file type icon and the brand type icon respectively. These styles will take precedence over the same styles coming from the CSS classes provided by the above 2 properties.
407+
408+
```json
409+
"elmType": "filepreview",
410+
"attributes": {
411+
"src": "@thumbnail.medium",
412+
},
413+
"filePreviewProps": {
414+
"fileTypeIconClass": "sp-css-borderColor-neutralLight",
415+
"fileTypeIconStyle": {
416+
"width": "100px"
417+
},
418+
"brandTypeIconClass": "sp-css-borderColor-neutralLight",
419+
"brandTypeIconStyle": {
420+
"width": "68px"
421+
}
422+
}
423+
```
387424

388425
## Expressions
389426

docs/images/image-helper-api-01.png

17.5 KB
Loading

docs/images/image-helper-api-02.png

131 KB
Loading

docs/spfx/image-helper-api.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Image Helper API
3+
description: Learn how to use the Image Helper API in the SharePoint Framework to provide web-friendly optimized image links.
4+
ms.date: 02/08/2022
5+
ms.prod: sharepoint
6+
ms.localizationpriority: high
7+
---
8+
# Image Helper API
9+
10+
The **ImageHelper** static class (in **\@microsoft\/sp-image-helper**) has been added to allow SPFx developers runtime access to:
11+
12+
- Urls of auto-generated thumbnail images of pages and documents stored in SharePoint
13+
- More optimized Urls to images stored in SharePoint
14+
15+
The helper method `ImageHelper.convertToImageUrl()` takes a Url to an asset on SharePoint, a width, and an optional height and will perform client-side operations to try to create an optimized Url.
16+
17+
The resulting Url will point to an image that is close to the requested size. The resulting Url will also include using other SharePoint media and graph services. If available for the requested asset, public or private CDN locations to serve the resized images and thumbnails.
18+
19+
> [!IMPORTANT]
20+
> The Image Helper API was introduced in the SharePoint Framework v1.14 release.
21+
22+
## Benefits to using this API
23+
24+
- The image may be delivered faster because it's potentially served out of a cache.
25+
- The image will be sized appropriately as width is required and height is optional. This allows for customers to store high-resolution images in SharePoint but not pay the download time penalty when those images are used.
26+
- The source Url maybe any filetype within SharePoint where a thumbnail can be generated. An image thumbnail Url would then be returned.
27+
28+
## Explained - ImageHelper.convertToImageUrl()
29+
30+
The `convertToImageUrl()` static method accepts a single argument of type **IImageHelperRequest**. This object has two required properties, `sourceUrl` & `width`, and one optional property `height`.
31+
32+
SharePoint's server-side image processing has a list of resolution breakpoints widths it supports, including: 200, 400, 960, 1600, & 2560.
33+
34+
While you can specify any width to resize the image to, SharePoint will pick the nearest largest resolution breakpoint. For example, if you specify `width: 250`, the resized image width will be 400 px.
35+
36+
If you specify the optional `height` property, SharePoint the width isn't adjusted to the nearest breakpoint. But if the `height property is omitted, SharePoint automatically determines the height of the resized image using the width & width breakpoint while maintaining the aspect ratio for the image.
37+
38+
> [!TIP]
39+
> Omitting the `height` property provides the quickest response from the SharePoint
40+
41+
## Use the Image Helper API
42+
43+
To use the Image Helper API, you must first install it into your project:
44+
45+
```console
46+
npm install @microsoft/sp-image-helper
47+
```
48+
49+
Next, import it into your project where you plan to use the API:
50+
51+
```typescript
52+
import { ImageHelper, IImageHelperRequest } from "@microsoft/sp-image-helper";
53+
```
54+
55+
Next, use the API to obtain a thumbnail image of an existing file in SharePoint. In this case, we've uploaded a file from the [Microsoft News Image Gallery](https://news.microsoft.com/imagegallery) site. In this example, we're using a file that's 1.2 MB in size with a resolution of 1920x1080... not an ideal web friendly format:
56+
57+
![Screenshot of the details panel of the original image.](../images/image-helper-api-01.png)
58+
59+
The file exists in our site's default **Documents** library:
60+
61+
```typescript
62+
const originalImageUrl = '/sites/dev002/Shared%20Documents/ignite2021-m365-keynote.jpeg';
63+
```
64+
65+
Use the Image Helper API to resize the image and use the new link to display the resized & optimized image:
66+
67+
```typescript
68+
const resizedImage = ImageHelper.convertToImageUrl(
69+
<IImageHelperRequest>{
70+
sourceUrl: originalImageUrl,
71+
width: 400
72+
}
73+
);
74+
75+
this.domElement.innerHTML = `
76+
<div class="${ styles.helloWorld }">New Image</div>
77+
<div><img src="${ resizedImage }" /></div>
78+
<div>
79+
<div>Original image URL: <a href="${originalImageUrl}">${originalImageUrl}</a>
80+
<div>Resized image URL: <a href="${resizedImage}">${resizedImage}</a>
81+
</div>
82+
`;
83+
```
84+
85+
![Screenshot of resized image.](../images/image-helper-api-02.png)
86+
87+
This resized image is only 30 kB in size with a resolution of 400x225, a significant improvement on the performance for the user. Notice the UrL of the resized image differs from the original Url we provided the helper method.
88+
89+
## Private CDN support
90+
91+
For the images to be available to be served from a private CDN, the following requirements must be met:
92+
93+
- the private CDN feature must be enabled
94+
- the source file must be available within an origin to the CDN
95+
- SharePoint's server-side preprocessing must know that the web part property is an image property
96+
97+
To make SharePoint's server-side processing aware of the image property, list the properties where image Urls are stored in the web part's **manifest.json** `imageLinkPropertyNames` property:
98+
99+
```json
100+
{
101+
"id": "374a1893-9b4d-4c10-bbe3-9411d74093e9",
102+
"alias": "HelloWorldWebPart",
103+
"componentType": "WebPart",
104+
"supportedHosts": [ "SharePointWebPart" ],
105+
"imageLinkPropertyNames": [ "defaultBannerImage" ],
106+
"preconfiguredEntries": [{
107+
"title": { "default": "HelloWorld" },
108+
"properties: {
109+
"defaultBannerImage": "..."
110+
}
111+
}]
112+
}
113+
```
114+
115+
This allows for SharePoint's server-side rewrite logic to include the mapping of that file to private CDN when rendering the page to be sent to the client.

docs/spfx/release-1.13.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ This release introduces a new component type, Adaptive Card Extensions (ACE), th
3737
- Update the Microsoft Teams SDK to v1.10.
3838
- Update React to v16.13.1.
3939
- Update TypeScript to v3.9.
40-
- Release of image rendering APIs for optimized performance
4140
- Numerous additional fixes and improvements based on issues reported by the community at https://aka.ms/spfx-issues
4241

4342
> [!NOTE]

docs/spfx/release-1.14.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ The default value of `isGroupNameHidden` is false.
155155
New property `ipAddress` has been added to `serve.json` configuration. This parameter is helpful when using Docker containers. For example, to set the serve host as '0.0.0.0'.
156156
This property will be explicitly used to wind up the server, meaning all debug URLs and webpack configurations will not be affected.
157157

158+
#### Image Helper API
159+
160+
The **ImageHelper** static class (in @microsoft/sp-image-helper) has been added to allow SPFx developers runtime access to:
161+
162+
- Urls of auto-generated thumbnail images of pages and documents stored in SharePoint
163+
- More optimized Urls to images stored in SharePoint
164+
165+
Learn more: [Image Helper API](image-helper-api.md)
166+
158167
## Preview Features and Capabilities
159168

160169
Following features are still in preview status as part of the 1.14 release and should not be used in production. We are looking into releasing them officially as part of the upcoming 1.15 release.
@@ -291,6 +300,7 @@ The Select Media Action can be used to select Images from your native device. In
291300

292301
![Screenshot of media panel](../images/release-notes/114/media-panel.jpg)
293302

303+
294304
## Deprecations and removed items in this release
295305

296306
> [!IMPORTANT]

docs/spfx/viva/get-started/advanced-card-view-functionality.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
title: Advanced Card View Functionality
33
description: "This tutorial builds off the tutorial 'Build your first SharePoint Adaptive Card Extension'."
4-
ms.date: 10/25/2021
4+
ms.date: 02/18/2022
55
ms.prod: sharepoint
66
ms.localizationpriority: high
77
---
88
# Advanced Card View Functionality
99

1010
This tutorial builds off the following tutorial: [Build your first SharePoint Adaptive Card Extension](build-first-sharepoint-adaptive-card-extension.md)
1111

12+
> [!IMPORTANT]
13+
> This feature is still preview status as part of the 1.14 release and should not be used in production. We are looking into releasing them officially as part of the upcoming 1.15 release.
14+
1215
In this tutorial, you'll implement advanced card view functionality. You'll build off the the previous tutorial and create a card view that's powered by data in a SharePoint list.
1316

1417
## Create a test list
@@ -410,6 +413,45 @@ Select the **Next** button until you get to the last item in the list. The card
410413

411414
:::image type="content" source="../../../images/viva-extensibility/lab2-ace-6.png" alt-text="Card displaying the last item in the list with only a Previous button":::
412415

416+
## Caching Card view and ACE state
417+
418+
Starting in SPFx v1.14, ACEs have a client-side caching layer that can be configured to store:
419+
420+
1. The latest rendered card.
421+
2. The state of the ACE.
422+
423+
### Rendering from cached Card view
424+
425+
If the latest rendered card is stored, the Dashboard renders this cached card before the ACE is initialized, improving perceived performance.
426+
427+
The settings for this cache can be configured by overriding the following method:
428+
429+
```typescript
430+
protected getCacheSettings(): Partial<ICacheSettings> {
431+
return {
432+
isEnabled: true, // can be set to false to disable caching
433+
expiryTimeInSeconds: 86400, // controls how long until the cached card and state are stale
434+
cachedCardView: () => new CardView() // function that returns the custom Card view that will be used to generate the cached card
435+
};
436+
}
437+
```
438+
439+
### Rehydrating from cached ACE state
440+
441+
The subset of the ACE state that is cached can be configured by overriding the following method:
442+
443+
```typescript
444+
protected getCachedState(state: TState): Partial<TState>;
445+
```
446+
447+
The object returned by this method will be serialized and cached. By default, no state is cached. In the next call to `onInit`, the deserialized value will be passed to onInit as part of the `ICachedLoadParameters`
448+
449+
```typescript
450+
public onInit(cachedLoadParameters?: ICachedLoadParameters): Promise<void>;
451+
```
452+
453+
The value can then be used to rehydrate the state of the newly initialized ACE.
454+
413455
## Conclusion
414456

415457
After this lab you should be familiar with:
@@ -419,3 +461,4 @@ After this lab you should be familiar with:
419461
- Creating and registering Card views
420462
- Conditionally rendering Card view elements
421463
- Advanced Card view manipulation
464+
- Caching Card view and ACE state

docs/spfx/web-parts/get-started/serve-your-web-part-in-a-sharepoint-page.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ You can also follow these steps by watching this video on the SharePoint PnP You
5050
}
5151
}
5252
```
53+
1. In the console window, enter the following command to bundle your client-side solution:
5354

55+
```console
56+
gulp bundle
57+
```
5458
1. In the console window, enter the following command to package your client-side solution that contains the web part:
5559

5660
```console

docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@
412412
href: spfx/use-theme-colors-in-your-customizations.md
413413
- name: Office UI Fabric integration
414414
href: spfx/office-ui-fabric-integration.md
415+
- name: Image Helper API
416+
href: spfx/image-helper-api.md
415417
- name: Tools & libraries
416418
items:
417419
- name: Overview

0 commit comments

Comments
 (0)