我在Github上主持一个Jekyll博客,用Markdown写我的帖子。当我添加图像时,我这样做:

![图片名称](http://link.com/image.jpg)

然后显示文本中的图像。

然而,我怎么能告诉Markdown添加一个标题是下面或上面的图像?


当前回答

你可以用表格。它工作得很好。

| ![space-1.jpg](http://www.storywarren.com/wp-content/uploads/2016/09/space-1.jpg) | 
|:--:| 
| *Space* |

结果:

其他回答

在_config. conf文件中添加如下配置。yml文件

# prose.io config
prose:
  rooturl: '_posts'
  media: 'img'
  ignore:
    - 404.html
    - LICENSE
    - feed.xml
    - _config.yml
    - /_layouts
    - /_includes
    - /css
    - /img
    - /js
  metadata:
    _posts:
      - name: "layout"
        field:
          element: "hidden"
          value: "post"
      - name: "title"
        field:
          element: "text"
          label: "Post title"
          placeholder: "Title"
          alterable: true
      - name: "subtitle"
        field:
          element: "textarea"
          label: "Subtitle"
          placeholder: "A description of your post."
          alterable: true
      - name: "date"
        field:
          element: "text"
          label: "Date"
          help: "Enter date of post."
          placeholder: "yyyy-mm-dd"
          alterable: true
      - name: "image"
        field:
          element: "text"
          label: "Image"
          help: "Add a thumbnail image to your post."
          placeholder: "Thumbnail"
          alterable: true
      - name: "published"
        field:
          element: "checkbox"
          label: "Publish"
          help: "Check to publish post, uncheck to hide."

您可以尝试使用pandoc作为您的转换器。这里有一个jekyll插件来实现这一点。Pandoc将能够自动添加与您的alt属性相同的图形标题。

但你必须推送编译后的网站,因为github不允许在github页面中使用插件。

我知道这是一个老问题,但我想我仍然要分享我的方法添加图片字幕。您将无法使用标题或figcaption标签,但这将是一个简单的替代方案,无需使用任何插件。

在你的标记中,你可以用强调标签包装标题,并将其直接放在图像的下面,而不需要插入新的行,如下所示:

![](path_to_image)
*image_caption*

这将生成以下HTML:

<p>
    <img src="path_to_image" alt>
    <em>image_caption</em>
</p>

然后在你的CSS中,你可以使用下面的选择器来设置它的样式,而不会干扰页面上的其他em标签:

img + em { }

注意,在图片和标题之间不能有空行,因为那样会生成:

<p>
    <img src="path_to_image" alt>
</p>
<p>
    <em>image_caption</em>
</p>

除了em,你也可以使用任何你想要的标签。只要确保有一个标签,否则你将无法设置它的样式。

你可以用表格。它工作得很好。

| ![space-1.jpg](http://www.storywarren.com/wp-content/uploads/2016/09/space-1.jpg) | 
|:--:| 
| *Space* |

结果:

Andrew的@andrew-wei回答很好。你也可以把几个链接在一起,这取决于你想要做什么。这,例如,让你的图像与alt,标题和标题与换行和粗体和斜体在标题的不同部分:

img + br + strong {margin-top: 5px; margin-bottom: 7px; font-style:italic; font-size: 12px; }
img + br + strong + em {margin-top: 5px; margin-bottom: 7px; font-size: 12px; font-style:italic;}

使用以下<img> markdown:

![description](https://img.jpg "description")
***Image:*** *description*