Can you add pictures to table cells using Google Docs API?

I’m trying to figure out how to put a picture in a table cell using the Google Docs API. I want to add an image to the first column of a 1x2 table. I looked at the docs but they say you can only put images inside paragraphs. They can’t go at the start of a table or in footnotes.

Has anyone done this before? I’m using Python and I’m not sure how to make it work. I want it to look like a picture inside a table cell. Any tips or code examples would be really helpful. I’ve been stuck on this for a while and I’m not sure what to try next.

# Example of what I'm trying to do
def add_image_to_cell(doc, table_index, row, col, image_url):
    # Not sure how to implement this
    pass

# Usage
add_image_to_cell(my_doc, 0, 0, 0, 'https://example.com/image.jpg')

Is there a way to do this or am I out of luck? Thanks for any help!

I’ve actually tackled this issue in a project and found that the Google Docs API does not directly support placing images inside table cells. In my experience, the solution was to create a paragraph within the table cell and then insert the image into that paragraph. I first built the table, then identified the target cell and embedded a new paragraph there. After that, I inserted the image into the paragraph, adjusting padding and alignment to achieve the desired look. Although the image is technically inside a paragraph, it effectively gives the appearance of being in the cell. If you need a solution without the paragraph wrapper, you might have to integrate with the Drive API for more granular control over element positioning.

I’ve encountered this limitation as well. The API doesn’t provide direct support for placing images into table cells, so a common workaround is to first insert a paragraph within the cell and then add the image into that paragraph. This method, although indirect, achieves the appearance of an image in the cell. To implement it, you would create your table, add the paragraph into the specific cell, and then insert the image while adjusting its size and alignment to fit. This solution is reliable for now, though future updates might offer a more direct approach.

hey zack, i had the same issue before. what worked for me was creating a paragraph in the cell first, then adding the image to that paragraph. it’s not perfect but it looks ok. you might need to play with the alignment and padding to make it look right. good luck with ur project!