From 9795f74f0f7495ebbc8945e43396cddb7c656431 Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Wed, 25 Feb 2026 21:52:51 +0100 Subject: [PATCH] feat: only attempt to parse image attachments --- attachment/attachment.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/attachment/attachment.go b/attachment/attachment.go index 06ce50c..727ec9f 100644 --- a/attachment/attachment.go +++ b/attachment/attachment.go @@ -222,10 +222,14 @@ func prepareAttachment(opener vfs.Opener, base, name string) (Attachment, error) Replace: name, } - // Try to detect image dimensions - if config, _, err := image.DecodeConfig(bytes.NewReader(fileBytes)); err == nil { - attachment.Width = strconv.Itoa(config.Width) - attachment.Height = strconv.Itoa(config.Height) + // Try to detect image dimensions if it's an image attachment + ext := strings.ToLower(filepath.Ext(name)) + switch ext { + case ".jpg", ".jpeg", ".png", ".gif": + if config, _, err := image.DecodeConfig(bytes.NewReader(fileBytes)); err == nil { + attachment.Width = strconv.Itoa(config.Width) + attachment.Height = strconv.Itoa(config.Height) + } } return attachment, nil