First image in the canvas as the card thumbnail?

I want to create a column of “Thumbnails” that fetches the content of the “Notes” column, which is of canvas type, and grabs the first occurrence of an image as the thumbnail.

Then, when I set the view type as cards, I could use this “thumbnails” column as the thumbnail for the cards.

Is this possible? I was playing with the formulas such as thisRow.Notes._merge().toText() to try and find the image URL, but I couldn’t figure it out.

Any help is much appreciated.

1 Like

Hey Larissa!
I’m afraid I came to the same conclusion as you in my experiment.
It might be possible with some pack :thinking:

1 Like

Yeah, no, gosh, I took a stab at this one and was unsuccessful.

Breaking the canvas down into its underlying JSON using [canvasColumn]._merge()+"" got me most of the way to reconstructing the imageURL, but as a security feature, every image url has a unique hash key, and I don’t believe there’s any way to access that (for good reason).

@Rickard_Abraham - I don’t even think there’s a Pack solution for this one

2 Likes

@Jon_Dallas @Rickard_Abraham
Hey guys, thank you for your replies!

I just wanted to let you know I managed to solve this and achieve what I wanted.
It is not in any way a straightforward method, as I had to convert the Canvas to HTML to expose the image URLs, and then use another pack to extract those URLs, but it does the job.

First, I used the Rich Text Tools pack by Eric Koleda to convert the content of the Canvas to HTML, and then I used the HTML pack by Filipe Fortes to extract a list of the image URLS.

So, the formula for the Thumbnail column of type Image URL looks like this:

if(
  thisRow.Notes,
  thisRow.Notes.[Rich Text Tools]::ToHTML().HTML::Images().First(),
  ""
)

At first, I tried using Coda’s native formula of RegexExtract() to extract the first image’s URL, but I am terrible at regex.

Eventually, I gave up on regex and used the Images() formula from the HTML pack, as it does exactly what I needed. If you are more experienced in Regex, you might be able to do it with a single pack instead of 2.

I hope this helps someone out there who might be facing the same issue :slightly_smiling_face:

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.