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.
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
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