From 07948ae7bc9019fa84ea49e61f5ac86a62da0ad8 Mon Sep 17 00:00:00 2001 From: camgraff <46980357+camgraff@users.noreply.github.com> Date: Wed, 14 Oct 2020 07:36:46 -0500 Subject: [PATCH] [MM-29224] Fix bug where markdown image link doesn't show preview (#15862) * Fix bug where markdown image has no preview * go fmt * Fix failing test Co-authored-by: Mattermod --- app/post_metadata.go | 4 ++++ app/post_metadata_test.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/post_metadata.go b/app/post_metadata.go index 143fe6eb95..8b4a89b913 100644 --- a/app/post_metadata.go +++ b/app/post_metadata.go @@ -316,6 +316,10 @@ func getFirstLinkAndImages(str string) (string, []string) { if firstLink == "" { firstLink = v.Destination() } + case *markdown.InlineLink: + if firstLink == "" { + firstLink = v.Destination() + } case *markdown.InlineImage: images = append(images, v.Destination()) case *markdown.ReferenceImage: diff --git a/app/post_metadata_test.go b/app/post_metadata_test.go index bc6cf706d9..0d494e4182 100644 --- a/app/post_metadata_test.go +++ b/app/post_metadata_test.go @@ -1280,11 +1280,11 @@ func TestGetFirstLinkAndImages(t *testing.T) { ExpectedFirstLink: "https://example.com", ExpectedImages: []string{"https://example.com/logo"}, }, - "markdown links (not returned)": { + "markdown links": { Input: `this is a [our page](http://example.com) and [another page][] [another page]: http://www.exaple.com/another_page`, - ExpectedFirstLink: "", + ExpectedFirstLink: "http://example.com", ExpectedImages: []string{}, }, } {