Fix preview or viewing of shared animated GIFs (#6386)
* Fix preview or viewing of shared animated GIFs --------- Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
This commit is contained in:
co-authored by
Roman Perekhod
parent
34909ec1fd
commit
e57e6046d3
@@ -80,6 +80,7 @@ func (e JpegEncoder) MimeType() string {
|
||||
|
||||
type GifEncoder struct{}
|
||||
|
||||
// Encode encodes the image to a gif format
|
||||
func (e GifEncoder) Encode(w io.Writer, img interface{}) error {
|
||||
g, ok := img.(*gif.GIF)
|
||||
if !ok {
|
||||
@@ -92,6 +93,7 @@ func (e GifEncoder) Types() []string {
|
||||
return []string{typeGif}
|
||||
}
|
||||
|
||||
// MimeType returns the mimetype used by the encoder.
|
||||
func (e GifEncoder) MimeType() string {
|
||||
return "image/gif"
|
||||
}
|
||||
@@ -110,3 +112,14 @@ func EncoderForType(fileType string) (Encoder, error) {
|
||||
return nil, ErrNoEncoderForType
|
||||
}
|
||||
}
|
||||
|
||||
// GetExtForMime return the supported extension by mime
|
||||
func GetExtForMime(mime string) string {
|
||||
ext := strings.TrimPrefix(strings.TrimSpace(strings.ToLower(mime)), "image/")
|
||||
switch ext {
|
||||
case typeJpg, typeJpeg, typePng, typeGif:
|
||||
return ext
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user