How to insert an inline image in Google Colaboratory from Google Drive

非 Y 不嫁゛ 提交于 2019-12-22 04:01:05

问题


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.


回答1:


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.




回答2:


According to the answers here

![](https://drive.google.com/uc?export=view&id=XXX)



回答3:


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:

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.




回答4:


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)



回答5:


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



来源:https://stackoverflow.com/questions/50670920/how-to-insert-an-inline-image-in-google-colaboratory-from-google-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!