Skip to content

Commit c16cde3

Browse files
committed
feat: Video thumbnail generation can be turned on/off #347
1 parent 9b90317 commit c16cde3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

projects/stream-chat-angular/src/lib/attachment-configuration.service.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,17 @@ describe('AttachmentConfigurationService', () => {
236236

237237
expect(result.url).toContain('h=750&w=600');
238238
});
239+
240+
it('should turn off thumbnail generation for video files', () => {
241+
service.shouldGenerateVideoThumbnail = false;
242+
243+
const attachment: Attachment = {
244+
asset_url: 'http://url/to/video',
245+
thumb_url: 'http://url/to/poster',
246+
};
247+
248+
expect(
249+
service.getVideoAttachmentConfiguration(attachment).thumbUrl
250+
).toBeUndefined();
251+
});
239252
});

projects/stream-chat-angular/src/lib/attachment-configuration.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export class AttachmentConfigurationService<
4040
customScrapedImageAttachmentConfigurationHandler?: (
4141
a: Attachment<T>
4242
) => AttachmentConfigration;
43+
/**
44+
* You can turn on/off thumbnail generation for video attachments
45+
*/
46+
shouldGenerateVideoThumbnail = true;
4347

4448
/**
4549
* Handles the configuration for image attachments, it's possible to provide your own function to override the default logic
@@ -95,7 +99,7 @@ export class AttachmentConfigurationService<
9599
}
96100

97101
let thumbUrl = undefined;
98-
if (attachment.thumb_url) {
102+
if (attachment.thumb_url && this.shouldGenerateVideoThumbnail) {
99103
const url = new URL(attachment.thumb_url);
100104
this.addResiziParamsToUrl({ width: 600, height: 600 }, url);
101105
thumbUrl = url.href;

0 commit comments

Comments
 (0)