Skip to content

Instantly share code, notes, and snippets.

@MichaelPolla
Last active May 22, 2024 19:00
Show Gist options
  • 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.

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