19

I want to downsize some of my images in my README.md on GitHub and it works fine in my Markdown editor using something like

![](./images/my_img.png =400x) 

However, when I upload it to GitHub, the Markdown viewer seems to not like it. Any suggestions or ideas how I can downsize the images without reducing the resolution of the images themselves?

0

2 Answers 2

43

Github doesn't apply the style attribute but obeys the width and height. So for github you can use the following HTML tag directly in the markdown:

<img src="url" alt="alt text" width="whatever" height="whatever"> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. The only challenge is then to get the aspect ratio right
Drop the height parameter to preserve the aspect ratio automatically.
13

You can use HTML syntax for the image directly in markdown

## Markdown Header This is a markdown paragraph. Etc. <img src="url" alt="alt text" style="width:whatever;height:whatever"> 

Update: As tzolov notes, GitHub doesn't actually permit inline styles. His technique does work, though.

6 Comments

is there a way I can set the height relative to the width (and vice versa), would make it easier, since the dimensions for the different images might be/are different
Um.. not sure if I understand @SebastianRaschka right, but simply specifying only width or height should scale the other dimension accordingly.
Doesn't work on github, image is there, but in its original size, github seems to filter out the style attribute...
Doesn't work, @tzolov's answer should be marked as correct one
style="" does not work in github. The post form @tzolov should appear higher.
|