diff --git a/config.sample.yaml b/config.sample.yaml index 795900e5e26be35f3c23fa901ddcd2cd264b9737..46681043ae0fd499dbf1cdfc39d47d776656b7b9 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -168,6 +168,9 @@ thumbnails: # thumbnails, set this to false. If disabled, regular thumbnails will be returned. allowAnimated: true + # Force animated thumbnails, if available + forceAnimated: true + # The maximum file size to thumbnail when a capable animated thumbnail is requested. If the image # is larger than this, the thumbnail will be generated as a static image. maxAnimateSizeBytes: 10485760 # 10MB default, 0 to disable diff --git a/src/github.com/turt2live/matrix-media-repo/client/r0/thumbnail.go b/src/github.com/turt2live/matrix-media-repo/client/r0/thumbnail.go index cd02d692acb384330ced3851c69a232c9fe85ca0..783c4ab98f5dad7b479847f4305a98194416d077 100644 --- a/src/github.com/turt2live/matrix-media-repo/client/r0/thumbnail.go +++ b/src/github.com/turt2live/matrix-media-repo/client/r0/thumbnail.go @@ -60,6 +60,10 @@ func ThumbnailMedia(w http.ResponseWriter, r *http.Request, log *logrus.Entry) i if method == "" { method = "scale" } + + if config.Get().Thumbnails.AllowAnimated && config.Get().Thumbnails.ForceAnimated { + animated = true + } log = log.WithFields(logrus.Fields{ "requestedWidth": width, diff --git a/src/github.com/turt2live/matrix-media-repo/config/config.go b/src/github.com/turt2live/matrix-media-repo/config/config.go index 3ac71e3ced4102cc30cfda039fb0cf0ba369509d..bfdd88a9468b6ea8a238ce46c03a9584382e3193 100644 --- a/src/github.com/turt2live/matrix-media-repo/config/config.go +++ b/src/github.com/turt2live/matrix-media-repo/config/config.go @@ -52,6 +52,7 @@ type ThumbnailsConfig struct { MaxAnimateSizeBytes int64 `yaml:"maxAnimateSizeBytes"` Sizes []*ThumbnailSize `yaml:"sizes,flow"` AllowAnimated bool `yaml:"allowAnimated"` + ForceAnimated bool `yaml:"forceAnimated"` } type ThumbnailSize struct { @@ -233,6 +234,7 @@ func NewDefaultConfig() *MediaRepoConfig { MaxAnimateSizeBytes: 10485760, // 10mb NumWorkers: 10, AllowAnimated: true, + ForceAnimated: true, Sizes: []*ThumbnailSize{ {32, 32}, {96, 96},