Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding an image stored in github

Tags:

html

github

I'm uploading a folder of images for a project to GitHub and I want to display them in Flask.

<img src="https://github.com/madelinekinnaird/Gerrymandr/blob/master/images/az1.PNG"> 

I'm having trouble getting this to work. Do I need to use another image storage site, or is it possible to use GitHub for this purpose?

like image 609
mk2080 Avatar asked Oct 18 '18 14:10

mk2080


People also ask

How do I embed an image in GitHub?

You can drag and drop the image from your computer to a comment field in GitHub. Wait for the file to upload and then the URL to the image is right there! You don't even have to submit the issue if you don't want to (although that may limit the image's lifespan).

Can I store images in GitHub?

GitHub remains one of the most reliable repository website for code, but we can also utilize its storage capability to host images for our website. The easiest way is simply to upload/push image files to your GitHub repo and get the link from the web.


2 Answers

Your approach looks correct. However, you are linking to the file in the github repository. Instead, you should link to image itself. You can get the link by right clicking on the image and select "copy image address".

In your case the link would be:

https://github.com/madelinekinnaird/Gerrymandr/blob/master/images/az1.PNG?raw=true

like image 99
Dominique Paul Avatar answered Sep 18 '22 18:09

Dominique Paul


Assuming your image are located at

https://github.com/userName/ImageRepo

Than to access that image from a browser use below link https://raw.githubusercontent.com/userName/ImageRepo/master/FileName.ext

eg: location: https://github.com/pavanghai/images/blob/master/wine_scatter.jpg

Browser link: https://raw.githubusercontent.com/pavanghai/images/master/wine_scatter.jpg

like image 37
Pavn Avatar answered Sep 20 '22 18:09

Pavn