Browse Source

utils: Fix loading animated images in encrypted rooms

merge-requests/2003/head
Kévin Commaille 11 months ago
parent
commit
57941187dd
No known key found for this signature in database
GPG Key ID: C971D9DBC9D678D
  1. 14
      src/utils/media/image/mod.rs

14
src/utils/media/image/mod.rs

@ -577,7 +577,10 @@ impl ThumbnailDownloader<'_> {
// First, select which source we are going to download from.
let source = if let Some(alt) = self.alt {
if !self.main.can_be_thumbnailed()
let is_animated = settings.animated && self.main.is_animated();
if !is_animated
&& !self.main.can_be_thumbnailed()
&& (filesize_is_too_big(self.main.filesize())
|| alt.dimensions().is_some_and(|s| s.ge(settings.dimensions)))
{
@ -590,7 +593,11 @@ impl ThumbnailDownloader<'_> {
self.main
};
if source.should_thumbnail(settings.prefer_thumbnail, settings.dimensions) {
if source.should_thumbnail(
settings.prefer_thumbnail,
settings.animated,
settings.dimensions,
) {
// Try to get a thumbnail.
let request = MediaRequestParameters {
source: source.source.to_common_media_source(),
@ -633,6 +640,7 @@ impl ImageSource<'_> {
fn should_thumbnail(
&self,
prefer_thumbnail: bool,
prefer_animated: bool,
thumbnail_dimensions: FrameDimensions,
) -> bool {
if !self.can_be_thumbnailed() {
@ -642,7 +650,7 @@ impl ImageSource<'_> {
// Even if we request animated thumbnails, not a lot of media repositories
// support scaling animated images. So we just download the original to be able
// to play it.
if self.is_animated() {
if prefer_animated && self.is_animated() {
return false;
}

Loading…
Cancel
Save