Bulk Upload Image in Attachment Column

Hi all,

I would like to know is there any way to upload an image in every row. Let’s say I have 100 rows, how could I upload every row with an image automagically? because it will take forever to upload manually. Thanks

1 Like

There isn’t a great way, but there is a way to work around it.

You can add a helper table (say, Helper), with a single row. Make a column of that table (say, column A) have the type Attachment. You can then bulk-upload all your attachments into that one cell.

From there, you can fill in attachments in a 100-row table using formulas. It’s tricky, and it would help if you can describe how you would know which attachment should go into which row. If you just want 100 rows, with one attachment in each, there is one horribly hacky way, but which seems to work:

  1. In your table Helper, add column B with the formula $A, and set its type to Reference List.
  2. Add a summary of the helper table, grouped by column B.
  3. In the new summary table (the one titled Helper [by B]), add a new column with the formula [$B], then set its type to Attachment.

This new column should now be an attachment column, with as many rows as you had attachments, one attachment in each. You can copy-paste this column into another table.

Wow! thanks so much @dmitry-grist. I’ve followed your step and it works well. But somehow, I can’t see the image but it shows the reference as snapshot below. Is it possible to see the image in the column?

I think maybe the formula in the last column (A) is set to $B? If so, add square brackets around it: [$B] – it makes it a Python list, and in Grist attachment columns are technically lists of attachments, so this bit is important.

1 Like

I updated this hack for the way attachments work today.

Problem

When I tried step 1 of @dmitry-grist’s solution, I couldn’t figure out what table to pick for the ref list type.

I tried picking the Helper table for the ref list type and fiddled with lots of ways of referring to these attachments in steps 1 and 3 (and switching between internal and external attachment storage), but nothing I did could both break them out into multiple rows (step 2) AND make it possible to retrieve them in a attachment column (step 3) without errors.

*I was actually troubleshooting a much more complicated doc and I’ll explain the extra stuff I had to do later, but for now, I’m using the terminology from the OP.

Key Observation

But, in my tinkering, I accidentally gave a column of integer values the attachment type. Suddenly, I could see attachments!

I think maybe at some point grist stopped treating attachments as ref lists and started accepted integer ids. I’m not sure. To be fair, I was

Solution

Once I discovered you can manually retrieve attachments by putting an integer value in an attachment column, I made the hack even hackier. I just needed a way to pass the ints through a ref list, summary and re-extract them into a formula-based attachment colum.

My new steps:

  1. I skipped this step because there was no valid table for the ref list:
    • In your table Helper, add column B with the formula $A, and set its type to Reference List.

  2. Add a summary of the helper table, grouped by column A (the raw attachments)
    • Note that I didn’t group by column B, since that doesn’t exist in my solution.
    • Also note that the summary table will have a column A that is all red with errors (essentially because it can’t render the grouped attachment as an attachment).
  3. In the new summary table (the one titled Helper [by **A**]), add a new column with the formula [int(str($C)[19:-1])], then set its type to Attachment.
    • yes, I got that hacky: str to substring to int to list to attachment.
    • but, it’s ok, because as with the original solution, you’ll just copy all these values into a new table anyway.

Bonus: I already had attachments!

So, I lied, my doc was more complicated. I already had (picture) attachments in a table I’ve used for at least a year, but I was sick of manually adding and deleting multiple pictures per field in the somewhat clunky attachment column type. I wanted to break those pictures out into another table with a single picture per row and bring them back into the original table via a ref list. This would make it much easier to manage info about the pictures and collaboratively prioritize them etc (building a photo book).

So, the extra complications were that I had to:

  • “move” attachments I already had (not just bulk upload new ones)
  • map these back to the original locations

So here my actual steps:

  1. grouped by my original Highlights table by the pics column and an id column.
  2. applied the string → int → attachment parsing formula above
  3. copied that into a new regular table of photos
  4. and finally, made a formula to map my id column back to the original highlights (two-way reference)