How to insert an inline image in Google Colaborato

2020-06-09 07:40发布

I am trying to insert an image in Google Colaboratory (markdown) already saved in Google Drive using this expression ![Text](https://xxxx) but it doesn't work. For example, the Colaboratory markdown manual shows how to insert a photo inline with this example An inline image: ![Google's logo](https://www.google.com/images/logos/google_logo_41.png). Ok, that is a photo from internet, but, when I replace that photo for one already saved in my Google Drive it doesn't appear.

5条回答
我想做一个坏孩纸
2楼-- · 2020-06-09 08:19

I tried all the answers above and nothing worked because of a small change Google has created recently(at the time of writing this post). If you click on "Get Shareable link" and paste it, it would look something like this:

https://drive.google.com/open?id=12BumFEqzKxc9mog8tYuUqvpxf10ot6W3

Now just change the open?id to uc?id and it will instantly work.

查看更多
在下西门庆
3楼-- · 2020-06-09 08:21

Unfortunately, I have tried the methods above but they didn't work for me. Then I have tried simply right-clicking on the picture that I want to display on colab, and choose 'Get a sharable link', then the link is automatically copied to my clipboard:

enter image description here

The link will be something like

https://docs.google.com/uc?id=-----

Then using colab's picture inserting button, and insert that link to the (https://) part

![picture](your link)

worked like a magic!

However, if you get a link like this

https://drive.google.com/file/d/-------/view?usp=sharing

after making picture public, it somehow doesn't work.

查看更多
Deceive 欺骗
4楼-- · 2020-06-09 08:22

According to the answers here

![](https://drive.google.com/uc?export=view&id=XXX)
查看更多
姐就是有狂的资本
5楼-- · 2020-06-09 08:30

Here is an example using plain html instead of markdown.

<figure>
<center>
<img src='https://drive.google.com/uc?id=1Rb6oXW3KufLApvID5MwxsknpoON2CkQ_' />
<figcaption>Image Caption</figcaption></center>
</figure>

This way, you can also center the image, add captions etc

查看更多
在下西门庆
6楼-- · 2020-06-09 08:31

From the next 3 formats only the first one worked for me:

![](https://drive.google.com/uc?export=view&id=0B3SU50kcW4Q4WFlla00tX3hkdkE)    
![](https://drive.google.com/file/d/0B3SU50kcW4Q4WFlla00tX3hkdkE)    
![](https://drive.google.com/open?id=0B3SU50kcW4Q4WFlla00tX3hkdkE)
查看更多
登录 后发表回答