diff --git a/kernel/sql/av_gallery.go b/kernel/sql/av_gallery.go index ac5886907..4d61ddbe8 100644 --- a/kernel/sql/av_gallery.go +++ b/kernel/sql/av_gallery.go @@ -201,7 +201,10 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View break } - galleryCard.CoverURL = assetValue.MAsset[0].Content + p := assetValue.MAsset[0].Content + if util.IsAssetsImage(p) { + galleryCard.CoverURL = p + } return case av.CoverFromContentBlock: blockValue := getBlockValue(cardValues) diff --git a/kernel/util/path.go b/kernel/util/path.go index 995cd03e6..d651dc829 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -317,6 +317,14 @@ var ( SiYuanAssetsVideo = []string{".mov", ".weba", ".mkv", ".mp4", ".webm"} ) +func IsAssetsImage(p string) bool { + ext := strings.ToLower(filepath.Ext(p)) + if "" == ext { + return false + } + return gulu.Str.Contains(ext, SiYuanAssetsImage) +} + func IsDisplayableAsset(p string) bool { ext := strings.ToLower(filepath.Ext(p)) if "" == ext {