MM-36295: Do not convert thumbnails/previews to jpeg for png images (#21230)
We were applying a white background to transparent images and converting them to jpegs. This was to make text be legible behind a black preview background. However, this has led to a poor user experience, as users rarely download the full image but always click on previews. Therefore, we need the previews to remain as pngs. To fix this, we just re-encode them as pngs instead of jpgs. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
79651874ea
Коммит
279c448da3
@@ -91,11 +91,11 @@ type Actions struct {
|
||||
CreateGroupChannel func(request.CTX, []string) (*model.Channel, *model.AppError)
|
||||
CreateChannel func(*model.Channel, bool) (*model.Channel, *model.AppError)
|
||||
DoUploadFile func(time.Time, string, string, string, string, []byte) (*model.FileInfo, *model.AppError)
|
||||
GenerateThumbnailImage func(image.Image, string)
|
||||
GeneratePreviewImage func(image.Image, string)
|
||||
GenerateThumbnailImage func(image.Image, string, string)
|
||||
GeneratePreviewImage func(image.Image, string, string)
|
||||
InvalidateAllCaches func()
|
||||
MaxPostSize func() int
|
||||
PrepareImage func(fileData []byte) (image.Image, func(), error)
|
||||
PrepareImage func(fileData []byte) (image.Image, string, func(), error)
|
||||
}
|
||||
|
||||
// SlackImporter is a service that allows to import slack dumps into mattermost
|
||||
@@ -793,13 +793,13 @@ func (si *SlackImporter) oldImportFile(timestamp time.Time, file io.Reader, team
|
||||
}
|
||||
|
||||
if fileInfo.IsImage() && !fileInfo.IsSvg() {
|
||||
img, release, err := si.actions.PrepareImage(data)
|
||||
img, imgType, release, err := si.actions.PrepareImage(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer release()
|
||||
si.actions.GenerateThumbnailImage(img, fileInfo.ThumbnailPath)
|
||||
si.actions.GeneratePreviewImage(img, fileInfo.PreviewPath)
|
||||
si.actions.GenerateThumbnailImage(img, imgType, fileInfo.ThumbnailPath)
|
||||
si.actions.GeneratePreviewImage(img, imgType, fileInfo.PreviewPath)
|
||||
}
|
||||
|
||||
return fileInfo, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user