Reputation: 109994
I am fairly new to markup (though it's extremely easy to pickup). I am working on a package and am trying to get the wiki pages looking nice as a help manual. I can insert a YouTube video link into the wiki page pretty easily but how do I embed a YouTube video. I know this may not be possible.
I have read you can use HTML tags so I tried embedding with HTML per this link as follows:
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/user/wwwLoveWatercom?v=BTRN1YETpyg" />
<param name="wmode" value="transparent" />
<embed src="http://www.youtube.com/user/wwwLoveWatercom?v=BTRN1YETpyg"
type="application/x-shockwave-flash"
wmode="transparent" width="425" height="350" />
</object>
And saved the page but nothing happened.
Upvotes: 498
Views: 316861
Reputation: 43593
Adding a link with the thumbnail, originally used by YouTube is a solution, that works. The thumbnail, used by YouTube is accessible the following way:
https://www.youtube.com/watch?v=5yLzZikS15k
https://img.youtube.com/vi/5yLzZikS15k/0.jpg
Following this logic, the code below produces flawless results:
<div align="left">
<a href="https://www.youtube.com/watch?v=5yLzZikS15k">
<img src="https://img.youtube.com/vi/5yLzZikS15k/0.jpg" style="width:100%;">
</a>
</div>
Adding a simple Play button, next to the thumbnail:
<div style="display: inline-flex; align-items: center;">
<!-- Video Thumbnail -->
<a href="https://www.youtube.com/watch?v=5yLzZikS15k" target="_blank" style="display: inline-block;">
<img src="https://img.youtube.com/vi/5yLzZikS15k/0.jpg" style="width: 100%; display: block;">
</a>
<!-- Play Button -->
<a href="https://www.youtube.com/watch?v=5yLzZikS15k" target="_blank" style="display: inline-block;">
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_play_button_icon_%282013%E2%80%932017%29.svg"
style="width: 50px; height: auto; margin-left: 5px;">
</a>
</div>
The button picture is taken from wikipedia commons, I hope it will stay there.
Upvotes: 21
Reputation: 2856
Why work so hard?
github.com allows dragging / dropping images & videos into Issues and PRs.
If you edit your README.md
on github.com and drag/drop an MP4 into the page, you get an embedded video player with audio (which you do not get with a GIF).
There is a size limit... I think it's 100 MB for assets uploaded this way.
.git
repo so does not impact clone speed or local repo sizehttps://github.com/huntharo/video-test
Upvotes: 9
Reputation: 839
Actually not only youtube, using a little trick you can upload any videos, even directly from your computer. To do that,
urls
from the video and image[](https://video-url.mp4)
Upvotes: 1
Reputation: 8408
In my case, as a trick I have encountered this issue by converting my screen recorded video into a gif using an online converter then I have added it to my markdown like so:
## Quick Overview of the project

The result was like this in the image below
Check this repo for a live preview of the example above. Hope this trick may help someone :).
Upvotes: 2
Reputation: 33214
Expanding on @MGA's Answer
While it's not possible to embed a video in Markdown you can "fake it" by including a valid linked image in your markup file, using this format:
[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE "Video Title")
If this markup snippet looks complicated, break it down into two parts:
an image

wrapped in a link
[link text](https://example.com/my-link "link title")
We are sourcing the thumbnail image directly from YouTube and linking to the actual video, so when the person clicks the image/thumbnail they will be taken to the video.
[](https://www.youtube.com/watch?v=StTqXEQ2l-Y "Everything Is AWESOME")
OR If you want to give readers a visual cue that the image/thumbnail is actually a playable video, take your own screenshot of the video in YouTube and use that as the thumbnail instead.
[](https://youtu.be/StTqXEQ2l-Y?t=35s "Everything Is AWESOME")
While this requires a couple of extra steps (a) taking the screenshot of the video and (b) uploading it so you can use the image as your thumbnail it does have 3 clear advantages:
Taking and uploading a screenshot takes a few seconds but has a big payoff.
Since this is standard markdown, it works everywhere. try it on GitHub, Reddit, Ghost, and here on Stack Overflow.
This approach also works with Vimeo videos
[](https://vimeo.com/3514904 "Little red riding hood - Click to Watch!")
Upvotes: 431
Reputation: 559
If you are trying to embed a video on a GitHub page all you need to do is go to the youtube video, click on share, copy the embed code (it should look like this)
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z7PExj_v-ZU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
and paste it to your markdown page.
Upvotes: 0
Reputation: 2312
You can try the following:
<iframe width="500" height="300" src="https://www.youtube.com/embed/<VIDEO_ID>" frameborder="0" allowfullscreen></iframe>
Upvotes: 0
Reputation: 8165
It's not possible to embed videos directly, but you can put an image which links to a YouTube video:
[](https://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
Upvotes: 795
Reputation: 45140
Center align Video with Thumbnail and Link:
<div align="center">
<a href="https://www.youtube.com/watch?v=StTqXEQ2l-Y">
<img
src="https://img.youtube.com/vi/StTqXEQ2l-Y/0.jpg"
alt="Everything Is AWESOME"
style="width:100%;">
</a>
</div>
Result:
Upvotes: 8
Reputation: 3113
Markdown does not officially support video embeddings but you can embed raw HTML in it. I tested out with GitHub Pages and it works flawlessly.
The snippet looks like:
<iframe width="560" height="315"
src="https://www.youtube.com/embed/MUQfKFzIOeU"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
PS: You can check out the live preview here
Upvotes: 62
Reputation: 345
If you like HTML tags more than markdown + center alignment:
<div align="center">
<a href="https://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE"><img src="https://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg" alt="IMAGE ALT TEXT"></a>
</div>
Upvotes: 19