Help

Re: Accessing attachment thumbnail URL from record value

Solved
Jump to Solution
1622 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Sticker_ninja
6 - Interface Innovator
6 - Interface Innovator

I’m building a custom app and need to show an attachment’s thumbnail image as part of an info card.

When I enter <div>{record.getCellValue("Attachment field")}</div> to view the cell values, I get the following error:

Error: Objects are not valid as a React child (found: object with keys {linkedRecordId, value}). If you meant to render a collection of children, use an array instead.

I’ve tried adding record.getCellValue("Attachment field").fields.url but it comes up as undefined.

I’ve also tried {record.map(value => {value.url})} to try access the object’s properties but map is not a function of record.

How can I access the thumbnail’s URL?

1 Solution

Accepted Solutions
Kamille_Parks
16 - Uranus
16 - Uranus

Try something like:

record.getCellValue("Attachment field")?.map(x => {
   var url= x.url
   return (<img src={url} />)
})

See Solution in Thread

4 Replies 4
Kamille_Parks
16 - Uranus
16 - Uranus

Try something like:

record.getCellValue("Attachment field")?.map(x => {
   var url= x.url
   return (<img src={url} />)
})
Emma_Yeap
Airtable Employee
Airtable Employee

Hi Michael,

Adding on to Kamille’s solution: the cell value formats for all the different field types are documented here: Airtable Blocks SDK

The cell value for attachment fields is an array of attachment objects (even if there’s only one attachment), so you’ll need to get the url(s) from those individual attachment objects.

Sticker_ninja
6 - Interface Innovator
6 - Interface Innovator

Right on, thanks to @Kamille_Parks and @Emma_Yeap I was able to piece it together:

{record.getCellValue("Lookup attachment field")?.map(x => {
    var url= x.value.thumbnails?.large?.url
    return (<img src={url} />)
})}

The extra value property is what allows this to work with a lookup field pointing to an attachment in another table if that is helpful to anyone.

To clarify for others only add .value if you’re pulling from a Lookup field. This question was asked regarding Attachment fields. Actual attachment fields do not return a value property within the object returned by .getCellValue().