@@ -30,6 +30,12 @@ import {getMediaByUrl} from "../utils/media";
30
30
// functions below create an instance of the Media class and are used throughout the
31
31
// project.
32
32
33
+ let USE_AUTHENTICATED_MEDIA = false ;
34
+
35
+ export function setUseAuthenticatedMedia ( use : boolean ) : void {
36
+ USE_AUTHENTICATED_MEDIA = use ;
37
+ }
38
+
33
39
/**
34
40
* A media object is a representation of a "source media" and an optional
35
41
* "thumbnail media", derived from event contents or external sources.
@@ -82,7 +88,7 @@ export class Media {
82
88
*/
83
89
public get srcHttp ( ) : string | null {
84
90
// eslint-disable-next-line no-restricted-properties
85
- return this . client . mxcUrlToHttp ( this . srcMxc , undefined , undefined , undefined , false , true ) || null ;
91
+ return this . client . mxcUrlToHttp ( this . srcMxc , undefined , undefined , undefined , false , true , USE_AUTHENTICATED_MEDIA ) || null ;
86
92
}
87
93
88
94
/**
@@ -92,7 +98,7 @@ export class Media {
92
98
public get thumbnailHttp ( ) : string | null {
93
99
if ( ! this . hasThumbnail ) return null ;
94
100
// eslint-disable-next-line no-restricted-properties
95
- return this . client . mxcUrlToHttp ( this . thumbnailMxc ! , undefined , undefined , undefined , false , true ) ;
101
+ return this . client . mxcUrlToHttp ( this . thumbnailMxc ! , undefined , undefined , undefined , false , true , USE_AUTHENTICATED_MEDIA ) ;
96
102
}
97
103
98
104
/**
@@ -109,7 +115,7 @@ export class Media {
109
115
width = Math . floor ( width * window . devicePixelRatio ) ;
110
116
height = Math . floor ( height * window . devicePixelRatio ) ;
111
117
// eslint-disable-next-line no-restricted-properties
112
- return this . client . mxcUrlToHttp ( this . thumbnailMxc ! , width , height , mode , false , true ) ;
118
+ return this . client . mxcUrlToHttp ( this . thumbnailMxc ! , width , height , mode , false , true , USE_AUTHENTICATED_MEDIA ) ;
113
119
}
114
120
115
121
/**
@@ -124,7 +130,7 @@ export class Media {
124
130
width = Math . floor ( width * window . devicePixelRatio ) ;
125
131
height = Math . floor ( height * window . devicePixelRatio ) ;
126
132
// eslint-disable-next-line no-restricted-properties
127
- return this . client . mxcUrlToHttp ( this . srcMxc , width , height , mode , false , true ) ;
133
+ return this . client . mxcUrlToHttp ( this . srcMxc , width , height , mode , false , true , USE_AUTHENTICATED_MEDIA ) ;
128
134
}
129
135
130
136
/**
0 commit comments