Generate preview regardless of HasPreviewImage value (#16535)

Automatic Merge
This commit is contained in:
Claudio Costa
2020-12-11 00:15:17 +01:00
committed by GitHub
parent 1367418e3c
commit 6c976c3b06
4 changed files with 24 additions and 12 deletions
+12
View File
@@ -404,6 +404,18 @@ func TestUploadFiles(t *testing.T) {
expectedImageHasPreview: []bool{true},
expectedCreatorId: th.BasicUser.Id,
},
// animated GIF
{
title: "Happy image thumbnail/preview 12",
names: []string{"testgif.gif"},
expectedImageThumbnailNames: []string{"testgif_expected_thumbnail.jpg"},
expectedImagePreviewNames: []string{"testgif_expected_preview.jpg"},
expectImage: true,
expectedImageWidths: []int{118},
expectedImageHeights: []int{118},
expectedImageHasPreview: []bool{false},
expectedCreatorId: th.BasicUser.Id,
},
{
title: "Happy admin",
client: th.SystemAdminClient,
+12 -12
View File
@@ -793,19 +793,19 @@ func (t *UploadFileTask) postprocessImage(file io.Reader) {
}
var wg sync.WaitGroup
wg.Add(1)
if t.fileinfo.HasPreviewImage {
wg.Add(2)
go func() {
defer wg.Done()
writeJPEG(genThumbnail(decoded), t.fileinfo.ThumbnailPath)
}()
wg.Add(3)
// Generating thumbnail and preview regardless of HasPreviewImage value.
// This is needed on mobile in case of animated GIFs.
go func() {
defer wg.Done()
writeJPEG(genThumbnail(decoded), t.fileinfo.ThumbnailPath)
}()
go func() {
defer wg.Done()
writeJPEG(genPreview(decoded), t.fileinfo.PreviewPath)
}()
go func() {
defer wg.Done()
writeJPEG(genPreview(decoded), t.fileinfo.PreviewPath)
}()
}
go func() {
defer wg.Done()
if t.fileinfo.MiniPreview == nil {
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB