@@ -96,6 +96,9 @@ export class Media {
9696 */
9797 public getThumbnailHttp ( width : number , height : number , mode : ResizeMethod = "scale" ) : string | null | undefined {
9898 if ( ! this . hasThumbnail ) return null ;
99+ // scale using the device pixel ratio to keep images clear
100+ width = Math . floor ( width * window . devicePixelRatio ) ;
101+ height = Math . floor ( height * window . devicePixelRatio ) ;
99102 return this . client . mxcUrlToHttp ( this . thumbnailMxc , width , height , mode ) ;
100103 }
101104
@@ -107,6 +110,9 @@ export class Media {
107110 * @returns {string } The HTTP URL which points to the thumbnail.
108111 */
109112 public getThumbnailOfSourceHttp ( width : number , height : number , mode : ResizeMethod = "scale" ) : string {
113+ // scale using the device pixel ratio to keep images clear
114+ width = Math . floor ( width * window . devicePixelRatio ) ;
115+ height = Math . floor ( height * window . devicePixelRatio ) ;
110116 return this . client . mxcUrlToHttp ( this . srcMxc , width , height , mode ) ;
111117 }
112118
@@ -117,6 +123,7 @@ export class Media {
117123 * @returns {string } An HTTP URL for the thumbnail.
118124 */
119125 public getSquareThumbnailHttp ( dim : number ) : string {
126+ dim = Math . floor ( dim * window . devicePixelRatio ) ; // scale using the device pixel ratio to keep images clear
120127 if ( this . hasThumbnail ) {
121128 return this . getThumbnailHttp ( dim , dim , 'crop' ) ;
122129 }
0 commit comments