Skip to content

Commit 1db38bc

Browse files
authored
Merge pull request #376 from GetStream/cdn-integration
Cdn integration
2 parents cdda666 + 53174b6 commit 1db38bc

25 files changed

+856
-297
lines changed
229 KB
Loading
336 KB
Loading
245 KB
Loading

docusaurus/docs/Angular/components/AttachmentListComponent.mdx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import AttachmentsScreenshot from "../assets/attachments-screenshot.png";
2+
import ImageSizingScreenshot1 from "../assets/image-sizing-screenshot-1.png";
3+
import ImageSizingScreenshot2 from "../assets/image-sizing-screenshot-2.png";
4+
import ImageSizingScreenshot3 from "../assets/image-sizing-screenshot-3.png";
25

3-
The `AttachmentList` compontent displays the attachments of a message. The following attachments are supported:
6+
The `AttachmentList` component displays the attachments of a message. The following attachments are supported:
47

58
- Images (including GIFs) are displayed inline
69
- Videos are displayed inline
@@ -40,5 +43,55 @@ You can use the [`AttachmentConfigurationService`](../services/AttachmentConfigu
4043

4144
You can provide your own attachment list component by the [`CustomTemplatesService`](../services/CustomTemplatesService.mdx)
4245

46+
### Image and video sizing
47+
48+
The following section details how the width and height of images and videos uploaded from files are computed.
49+
50+
#### Maximum size
51+
52+
You can control the maximum size of images and videos with the [`--str-chat__attachment-max-width`](../theming/component-variables.mdx) CSS variable (available only in [theme-v2](../theming/introduction.mdx)). The value of this variable must be a value that can be computed to a valid pixel value using the [`getComputedStyle`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) method (for example: `300px`, `10rem`, `calc(300px - var(--margin))`, but not `100%`). If you provide an invalid value, the image and video sizing can break, which can lead to scrolling issues inside the message list (for example the message list isn't scrolled to the bottom when you open a channel).
53+
54+
:::tip
55+
If you're unsure about the value you provided for `--str-chat__attachment-max-width`, send an image/video to a channel, then inspect the `img`/`video` element inside the message list using your browser's development tools. Inside the **computed** properties of the element, you should see that `max-height` and `max-width` are set to a valid pixel value.
56+
:::
57+
58+
#### File size optimization
59+
60+
Based on the CSS settings provided for images and videos, the SDK will load an image (or thumbnail image in case of a video file) with a reduced file size while still providing sufficient image quality for the given dimensions. This will result in less network traffic and faster image load for users.
61+
62+
#### Aspect ratio
63+
64+
The following description is applicable for [theme-v2](../theming/introduction.mdx).
65+
66+
The SDK will try to display images and videos with their original aspect ratio, however this isn't always guaranteed (in those cases a cropped image will be displayed). Three notable exceptions are:
67+
68+
1. if a message contains multiple lines of texts and/or multiple attachments, the image/video might be stretched to its `max-width`
69+
70+
**Example 1** - message with one line of text
71+
72+
<img src={ImageSizingScreenshot1} width="200" />
73+
74+
**Example 2** - message with multiple lines of text
75+
76+
<img src={ImageSizingScreenshot2} width="200" />
77+
78+
2. in Safari, images/videos with portrait orientation are stretched to `max-width`
79+
80+
**Example 3** - portrait images in Safari
81+
82+
<img src={ImageSizingScreenshot3} width="200" />
83+
84+
3. if the image/video can't be rendered with the original aspect ratio given the `max-width` and `max-height` constraints of the host HTML element
85+
86+
:::important
87+
**File size optimization** and maintaining **aspect ratio** uses features provided by Stream's CDN. If you're using your **own CDN** you'll likely have to provide your own implementation for this. You can do this using the [`AttachmentConfigurationService`](../services/AttachmentConfigurationService.mdx).
88+
:::
89+
90+
:::danger
91+
**If you're planning to rewrite attachment sizing with your own CSS code** it's important to note that:
92+
93+
The sizing logic for images and videos inside the [`AttachmentConfigurationService`](../services/AttachmentConfigurationService.mdx) requires that host elements of images and videos (ususally `img` and `video` elements) have `max-height`/`height` and `max-width` properties defined and that these values can be computed to a valid pixel value using the [`getComputedStyle`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) (for more information refer to the [Maximum size](#maximum-size) section).
94+
:::
95+
4396
[//]: # "Start of generated content"
4497
[//]: # "End of generated content"

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@ngx-translate/core": "^13.0.0",
118118
"@ngx-translate/http-loader": "^6.0.0",
119119
"@popperjs/core": "^2.11.5",
120-
"@stream-io/stream-chat-css": "3.0.0-theming2.8",
120+
"@stream-io/stream-chat-css": "3.0.0-theming2.11",
121121
"@stream-io/transliterate": "^1.5.2",
122122
"angular-mentions": "^1.4.0",
123123
"dayjs": "^1.10.7",

0 commit comments

Comments
 (0)