Is there a way to add an animated GIF to a Markdown file?
Asked Answered
M

13

473

I want to add this animated GIF to a GitHub flavored markdown file. If it can't be done in GitHub, is it possible to do it in another version of Markdown?

Murex answered 17/12, 2015 at 18:32 Comment(1)
Possible duplicate of How to add screenshot to READMEs in github repository ? or Add images to README.md on githubFirstly
W
979

Showing gifs need two things

1- Use this syntax as in these examples

![Alt Text](https://media.giphy.com/media/vFKqnCdLPNOKc/giphy.gif)

Yields:

Alt Text

2- The image url must end with gif

3- For posterity: if the .gif link above ever goes bad, you will not see the image and instead see the alt-text and URL, like this:

Alt Text

4- for resizing the gif you can use this syntax as in this Github tutorial link

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

Yields:

Word answered 21/2, 2017 at 11:42 Comment(7)
Please note that if your gif is too large, you will see a bad image box. Smaller gifs will work just fine.Fortran
@jibeeeee Thanks to "Rick supports Monica" user. He is the one who added the Cat's imageWord
fwiw, I was able to add a GitHub-hosted gif to a GitHub gist even though the file url didn't end with .gifAgglutinative
@Agglutinative Well that is good. Maybe things have changed. I don't know. That was the case when I wrote this answerWord
I seem to have a funny one with it not working at all! does work if I change to a different gif image though.Mede
And just like that, this cat became the most popular placeholder gif across the globeShaffer
upvoted for catBarramunda
R
134

From the Markdown Cheatsheet:

You can add it to your repo and reference it with an image tag:

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"

Inline-style: alt text

Reference-style: alt text


Alternatively you can use the url directly:

![](http://www.reactiongifs.us/wp-content/uploads/2013/10/nuh_uh_conan_obrien.gif)
Rochellerochemont answered 17/12, 2015 at 18:35 Comment(0)
P
34
  1. have gif file.
  2. push gif file to your github repo
  3. click on that file on the github repo to get github address of the gif
  4. in your README file: ![alt-text](link)

example below: ![grab-landing-page](https://github.com/winnie1312/grab/blob/master/grab-landingpage-winnie.gif)

Positively answered 23/4, 2018 at 15:6 Comment(1)
It's easier to put it in a repo directory like /img and then use ![alt text](img/my-image.png)Selfstarter
C
28

just upload the .gif file into your base folder of GitHub and edit README.md just use this code

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

Clockwise answered 29/10, 2019 at 13:24 Comment(0)
S
13

Upload from local:

  1. Add your .gif file to the root of Github repository and push the change.
  2. Go to README.md
  3. Add this ![Alt text](name-of-gif-file.gif) / ![](name-of-gif-file.gif)
  4. Commit and gif should be seen.

Show the gif using url:

  1. Go to README.md
  2. Add in this format ![Alt text](https://sample/url/name-of-gif-file.gif)
  3. Commit and gif should be seen.

Hope this helps.

Sharpen answered 25/3, 2020 at 17:47 Comment(1)
This would add an additional binary file to the repository. increases repo sizeAnasarca
E
12

Giphy Gotcha

After following the 2 requirements listed above (must end in .gif and using the image syntax), if you are having trouble with a gif from giphy:

Be sure you have the correct giphy url! You can't just add .gif to the end of this one and have it work.

If you just copy the url from a browser, you will get something like:

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

You need to instead click on "Copy Link" and then grab the "GIF Link" specifically. Notice the correct one points to media.giphy.com instead of just giphy.com:

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

Eductive answered 13/3, 2018 at 20:6 Comment(0)
C
10

Another simpler way is to open your git repository in your browser (chrome), click on edit README.md

then just drag drop your gif/png/jpeg file from your local machine disk and automatically the file will be uploaded and link will be placed in README.md file, like shown below

![myfile](https://user-images.githubusercontent.com/52455330/139071980-91302a8a-37b1-4196-803e-f91b1de2ee5b.gif)

myfile

The file you wanted to be added

myfile

![myfile](https://www.reactiongifs.us/wp-content/uploads/2013/10/nuh_uh_conan_obrien.gif)
Conjuncture answered 27/10, 2021 at 13:9 Comment(0)
S
6

Using HTML's img tag then giving a source url.

<img src="https://...thumbs-up.gif">

enter image description here

Stalingrad answered 2/2, 2022 at 15:48 Comment(0)
F
5

If you can provide your image in SVG format (it is an icon and not a photo), it can be animated with SVG SMIL animations and SVG would be definitely the superior alternative to GIF images (or even other formats).

SVG, like other image formats, can be used with either standard markup or HTML <img> element:

![image description](path/in/repository/to/image.svg)
<img src="path/in/repository/to/image.svg" width="128"/>
Floristic answered 23/9, 2020 at 14:29 Comment(0)
M
2

in addition to all answers above:

if you want to use a gif for your github repository README.md and don't want to address it from your root directory, it's not enough if you just copy the url of your browser, for example your browser URL is sth like:

https://github.com/ashkan-nasirzadeh/simpleShell/blob/master/README%20assets/shell-gif.gif

but you should open your gif in your github account and right click on it and click copy image address or sth like that which is sth like this:

https://github.com/ashkan-nasirzadeh/simpleShell/blob/master/README%20assets/shell-gif.gif?raw=true

Masterwork answered 26/11, 2019 at 1:0 Comment(0)
P
2

you can use ![ ](any link of image)

Also I would suggest to use https://stackedit.io/ for markdown formating and wring it is much easy than remembering all the markdown syntax

Pusillanimity answered 22/9, 2020 at 18:46 Comment(0)
E
1

Convert the url from

https://github.com/nikhith265/submit_button_group/blob/master/attachments/gif/sample_gif.gif

to

https://raw.githubusercontent.com/nikhith265/submit_button_group/298c26b5a3fcfe936f16deef0e8712c2fdc1b635/attachments/gif/sample_gif.gif

NOTE: Make sure to remove /blob from url

Then use img tag as follows to add gif to .md

<img src="https://raw.githubusercontent.com/nikhith265/submit_button_group/298c26b5a3fcfe936f16deef0e8712c2fdc1b635/attachments/gif/sample_gif.gif" alt="gif" width="300" height="540">
Eldenelder answered 23/12, 2022 at 3:54 Comment(0)
H
1

The easiest way that I found to add a gif to a markdown file is just copy/paste. Nearly most of Microsoft's websites like GitHub, Stack Overflow support copying/pasting images and gifs.

If you have the file in your computer, then copy it and paste in any markdown file and it will be added automatically and uploaded to GitHub's server and formatted in the correct format with the name of the file.

enter image description here

Help answered 1/8, 2023 at 20:39 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.