17

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?

3
  • 2
    Try opening that URL in your browser. It takes you to a webpage, not an image file. Commented Oct 18, 2018 at 14:28
  • 1
    I don't think you should use github as a static files host. This may even violate the TOS Commented Oct 18, 2018 at 14:28
  • 2
    <img src="https://raw.githubusercontent.com/madelinekinnaird/Gerrymandr/master/images/az1.PNG"> Commented Oct 18, 2018 at 14:31

2 Answers 2

26

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

Sign up to request clarification or add additional context in comments.

Comments

7

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

2 Comments

I am creating an android app and thinking to store 300+ images there. I want to ask will GitHub block my app user IP if they send too many requests to access the image?
It will be definitely better to use some S3 object storage for this case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.