Generate preview regardless of HasPreviewImage value (#16535)

Automatic Merge
Этот коммит содержится в:
Claudio Costa
2020-12-11 00:15:17 +01:00
коммит произвёл GitHub
родитель 1367418e3c
Коммит 6c976c3b06
4 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@@ -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,

Просмотреть файл

@@ -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 {

Двоичные данные
tests/testgif_expected_preview.jpg Обычный файл

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.7 KiB

Двоичные данные
tests/testgif_expected_thumbnail.jpg Обычный файл

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.2 KiB