Skip to content

Instantly share code, notes, and snippets.

@MichaelPolla
Last active May 12, 2024 06:24
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save MichaelPolla/a65ac84286ab523603e64549f9850223 to your computer and use it in GitHub Desktop.
Save MichaelPolla/a65ac84286ab523603e64549f9850223 to your computer and use it in GitHub Desktop.
Markdown - Resize pictures in GitHub, including in comments comment

Markdown - Resize pictures in GitHub

I found that the "best" way is to use HTML, as it works both in Readme/.md files and also in comments (within Issues, Gist...)

E.g. when adding/editing a comment (within Issues, Gist...) :

  • Upload the picture by drag-and-drop in the text field
  • replace ![image](https://your-image-url.type) with <img src="https://your-image-url.type" width="100" height="100">

As mentioned by @cbestow (thanks!), it's not mandatory to set both width and height. If only one is set, the other will be adjusted accordingly to preserve the aspect ratio of the image.

@vjreddy2001
Copy link

Thank you, this worked

@yvonneywchen
Copy link

It works.

@rodrigonoal
Copy link

Thank you very much! Finally added a pretty profile readme hahahahaha

@vkhang55
Copy link

So awesome!

@fabiomen10
Copy link

Thanks, too!

@corquaid
Copy link

Great tip. Thanks!!

@Keevanrosenlund
Copy link

Much appreciated thanks!

@maiduydung
Copy link

Thank you!

@manikantag
Copy link

Thanks, it worked

@javadr
Copy link

javadr commented Sep 21, 2021

Nice tip. Thanks.

@VenkataRavitejaGullapudi

Useful one

@trisha
Copy link

trisha commented Dec 6, 2021

Thank you for this!

Can also use: <img src="https://your-image-url.type" width="50%" height="50%">

@araxis
Copy link

araxis commented Dec 19, 2021

Thank you.

@itbj
Copy link

itbj commented Dec 27, 2021

Thank you.

@chriscomeau
Copy link

🙏

@angshumatic
Copy link

Wow thanks. How about aligning the image to the right?

@Qingqing-Yang-177
Copy link

Really helpful! Thanks

@CamilleA3
Copy link

thanks a lot! you guys can also replace the height and width with percentile values e.g., width="60%" height="50%"

You really saved my life by reminding me I can do this!!!

@anfisc
Copy link

anfisc commented Oct 28, 2022

Thank you very much. This helped me a lot!

@Ethan00Si
Copy link

Thank you!!! It works well:)

Copy link

ghost commented Aug 31, 2023

Beautiful!

@OlgaErshova1
Copy link

Thank you, worked for me

@RymMichaut
Copy link

worked for me too. Thanks :) well explained

@mahnazmh
Copy link

mahnazmh commented Oct 3, 2023

Thank you :)

@HOSS11H
Copy link

HOSS11H commented Oct 13, 2023

thx

@VASANTHAPUVVADA
Copy link

Good

@vilsi12
Copy link

vilsi12 commented Jan 3, 2024

Thank you it works for me

@k-Gillespie
Copy link

k-Gillespie commented Mar 21, 2024

can confirm it works well, thank you.

@effiban
Copy link

effiban commented Apr 10, 2024

thanks!!

@xiaotianxt
Copy link

Does anyone know a way to keep aspect ratio during the image loading? If I use

<img width="100%" style="aspect-ratio: 16 / 9" src="xxx" >

Github will remove the style attribute, and it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment