python - 重构文本中的鹈鹕外部图像

标签 python image restructuredtext pelican

我想把外部图片放在我用 Pelican 创建的博客上

所以我尝试:

some text

.. image:: http://example.com/image.png
    :alt: Alt text

运行“pelican -s pelicanconf.py”后出现错误:

ERROR: Better Fig. Error: image not found: /Users/kendriu/sources/pelican-blog/contenthttp:/example.com/image.png
ERROR: Could not process ./4_joe.rst
   | [Errno 2] No such file or directory: u'/Users/kendriu/sources/pelican-blog/contenthttp:/example.com/image.png'

我的帖子里没有图片。

问题是:如何将外部图片放入我的博客。

最佳答案

Pelican 期望路径位于内容目录中。总的来说,这是一个好主意,因为拉取内容并使用其他人的带宽是不友善的。

您必须像这样使用原始标签来执行此操作:

.. raw:: html 
      <img src="http://example.com/image.jpg" alt="alt text">

最好的解决方案是下载图像(假设您有权限),然后将其包含在您的内容文件夹中,然后自行托管,这是一种默认行为。

更新

要托管来自谷歌驱动器的图像,请参阅此讨论:Displaying files (e.g. images) stored in Google Drive on a website

Mori 的解决方案对我有用:

https://drive.google.com/uc?id=FILE-ID

在上面的例子中转化为:

.. raw:: html 
      <img src="https://drive.google.com/uc?id=0B9o1MNFt5ld1N3k1cm9tVnZxQjg">

使用 Google Drive API 的效果非常好。

关于python - 重构文本中的鹈鹕外部图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28706806/

相关文章:

android - 透明PNG图像看起来不好看

restructuredtext - 将链接插入reStructuredText中的粗体文本

javascript - 查找给定数字 n 的所有偶因式分解 - javascript python

python - 在 python 中编程时钟时,如何允许用户输入自己的当前时间值?

image - Matlab imwarp,图像不适合

css - 垂直半页背景图像(在 Squarespace 中)

svg - Sphinx的html输出中的svg图比例(其余)

html - 将 CSS 类添加到 RST 中的链接

python - Tornado :AttributeError: 'StaticHandler' 对象没有属性 'absolute_path'

python - 将回历(伊斯兰日期)转换为公历