有没有办法将GIF添加到Markdown文件?

时间:2015-12-17 18:32:53

标签: markdown gif github-flavored-markdown

我想将此gif添加到GitHub风格的markdown文件中。如果它不能在GitHub中完成,是否可以在另一个版本的markdown中完成?

9 个答案:

答案 0 :(得分:321)

显示GIF需要两件事

1-使用these examples

中的语法

<img src="https://media.giphy.com/media/vFKqnCdLPNOKc/giphy.gif" width="40" height="40" />

收率:

Alt Text

2-图片网址必须以gif

结尾

3-对于后人:如果上面的.gif链接变坏,你将看不到图像,而是看到alt文本和URL,如下所示:

Alt Text

4-用于调整gif的大小,您可以使用此Github tutorial link

中的语法
{{1}}

收率:

答案 1 :(得分:96)

来自Markdown Cheatsheet

您可以将其添加到您的仓库并使用图片代码引用它:

Inline-style: 
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")

Reference-style: 
![alt text][logo]

[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"

内嵌式: alt text

参考式: alt text

或者,您可以使用the url directly

![](http://www.reactiongifs.us/wp-content/uploads/2013/10/nuh_uh_conan_obrien.gif)

答案 2 :(得分:5)

Giphy Gotcha

遵循上面列出的2个要求(必须以.gif结尾并使用图像语法),如果您遇到giphy的gif有问题:

请确保您拥有正确的giphy网址! 您不能只将.gif添加到此版本的末尾并使其正常工作。

如果您只是从浏览器中复制网址,您将获得类似的内容:

https://giphy.com/gifs/gol-automaton-game-of-life-QfsvYoBSSpfbtFJIVo

您需要点击“复制链接”,然后专门抓取“GIF链接”。请注意,正确的一个指向media.giphy.com而不是giphy.com

https://media.giphy.com/media/QfsvYoBSSpfbtFJIVo/giphy.gif

答案 3 :(得分:4)

  1. 有gif文件。
  2. 将gif文件推送到您的github repo
  3. 点击github repo上的那个文件,获取gif的github地址
  4. 您的README文件中的
  5. ![alt-text](link)
  6. 以下示例: ![grab-landing-page](https://github.com/winnie1312/grab/blob/master/grab-landingpage-winnie.gif)

答案 4 :(得分:3)

从本地上传:

  1. 将您的.gif文件添加到Github存储库的根目录并推送更改。
  2. 转到README.md
  3. 添加此![Alt text](name-of-gif-file.gif) / ![](name-of-gif-file.gif)
  4. 应该看到Commit和gif。

使用网址显示gif:

  1. 转到README.md
  2. ![Alt text](https://sample/url/name-of-gif-file.gif)的格式添加
  3. 应该看到Commit和gif。

希望这会有所帮助。

答案 5 :(得分:1)

您可以使用![](图像的任何链接)

我还建议使用https://stackedit.io/进行降价格式化,并且比记住所有降价语法要容易得多

答案 6 :(得分:0)

只需将.gif文件上传到GitHub的基本文件夹中,然后编辑README.md,只需使用此代码即可

![](name-of-giphy.gif)

答案 7 :(得分:0)

除了以上所有答案:

如果您想为github存储库README.md使用gif,并且不想从根目录使用它,仅复制浏览器的URL还是不够的。例如,您的浏览器网址如下:

select * from messages t1 inner join( select row_number() over (partition by user_id order by conversation_id desc) rn, conversation_id, user_id from conversations_users) t2 on t1.user_id = t2.user_id where rn <= 100 order by created_at asc;

但是您应该在github帐户中打开gif并点击,然后单击https://github.com/ashkan-nasirzadeh/simpleShell/blob/master/README%20assets/shell-gif.gif或类似的内容:

copy image address

答案 8 :(得分:0)

如果您可以提供SVG格式的图像,并且它是图标而不是照片,因此可以用SMIL动画进行动画处理,那么它绝对是gif图像(甚至其他图像)的绝佳替代品格式)。

与其他图像文件一样,SVG图像可以与标准标记或HTML <img>元素一起使用:

![image description](the_path_to/image.svg)
<img src="the_path_to/image.svg" width="128"/>