Support for image resizing #206

Closed
opened 2026-01-29 14:30:20 +00:00 by claunia · 10 comments
Owner

Originally created by @seanmcilvenna on GitHub (May 7, 2018).

It would be good if Markdig supported image re-sizing.
For example, some implementations of Markdown support the following:
![](http://example.com/image.jpg =250x25)
or
![](http://example.com/image.jpg =250)
The result would be:
<img src="http://example.com/image.jpg" width="250" height="25" />
and
<img src="http://example.com/image.jpg" width="250" height="250" />

Originally created by @seanmcilvenna on GitHub (May 7, 2018). It would be good if Markdig supported image re-sizing. For example, some implementations of Markdown support the following: `![](http://example.com/image.jpg =250x25)` or `![](http://example.com/image.jpg =250)` The result would be: `<img src="http://example.com/image.jpg" width="250" height="25" />` and `<img src="http://example.com/image.jpg" width="250" height="250" />`
claunia added the questionenhancement labels 2026-01-29 14:30:20 +00:00
Author
Owner

@MisinformedDNA commented on GitHub (May 25, 2018):

Yes, I was just looking for that as well. I read through the CommonMark spec and see that I can use this workaround:

<DIV STYLE="WIDTH:400px">

![](../images/asd.jpg)

</DIV>

But that's ugly and dirty.

@MisinformedDNA commented on GitHub (May 25, 2018): Yes, I was just looking for that as well. I read through the CommonMark spec and see that I can use this workaround: ``` <DIV STYLE="WIDTH:400px"> ![](../images/asd.jpg) </DIV> ``` But that's ugly and dirty.
Author
Owner

@xoofx commented on GitHub (May 25, 2018):

It would be good if Markdig supported image re-sizing.
For example, some implementations of Markdown support the following:
![](http://example.com/image.jpg =250x25)

Not sure it is a good idea to add an extension for changing the CommonMark URL syntax... but you should be able to do this with the special attributes extension. Check this on babelmark with the markdig (advanced) output:

![](http://example.com/image.jpg){width=250 height=120}
___
<img src="http://example.com/image.jpg" width="250" height="120" alt="">

This syntax is supported by pandoc as well.

@xoofx commented on GitHub (May 25, 2018): > It would be good if Markdig supported image re-sizing. > For example, some implementations of Markdown support the following: > `![](http://example.com/image.jpg =250x25)` Not sure it is a good idea to add an extension for changing the CommonMark URL syntax... but you should be able to do this with the [special attributes extension](https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/GenericAttributesSpecs.md). Check this on [babelmark](https://babelmark.github.io/?text=!%5B%5D(http%3A%2F%2Fexample.com%2Fimage.jpg)%7Bwidth%3D250+height%3D120%7D) with the `markdig (advanced)` output: ``` ![](http://example.com/image.jpg){width=250 height=120} ___ <img src="http://example.com/image.jpg" width="250" height="120" alt=""> ``` This syntax is supported by pandoc as well.
Author
Owner

@MisinformedDNA commented on GitHub (May 25, 2018):

The CommonMark syntax already allows for similar syntax for links

[link](/uri "title")

We would just add similar functionality for images

![alt_text](/uri sizing)

But I see this is not widely supported either. So that's unfortunate.

That said, what is the difference between markdig and markdig (advanced)?

@MisinformedDNA commented on GitHub (May 25, 2018): The CommonMark syntax already allows for similar [syntax for links](https://spec.commonmark.org/0.28/#example-459) ``` [link](/uri "title") ``` We would just add similar functionality for images ``` ![alt_text](/uri sizing) ``` But I see this is not widely supported either. So that's unfortunate. That said, what is the difference between `markdig` and `markdig (advanced)`?
Author
Owner

@xoofx commented on GitHub (May 25, 2018):

That said, what is the difference between markdig and markdig (advanced)?

It is configuring markdig pipeline with most of all available extensions (as described here)

@xoofx commented on GitHub (May 25, 2018): > That said, what is the difference between markdig and markdig (advanced)? It is configuring markdig pipeline with most of all available extensions (as described [here](https://github.com/lunet-io/markdig#usage))
Author
Owner

@seanmcilvenna commented on GitHub (May 25, 2018):

So, why was this closed? Are we saying this is already supported by "markdig advanced"?
What is the solution that warrants closing this?

@seanmcilvenna commented on GitHub (May 25, 2018): So, why was this closed? Are we saying this is already supported by "markdig advanced"? What is the solution that warrants closing this?
Author
Owner

@xoofx commented on GitHub (May 25, 2018):

So, why was this closed? Are we saying this is already supported by "markdig advanced"?
What is the solution that warrants closing this?

  • There is a already a way to define resize through attributes.
  • I don't see the value of adding a syntax that is not used by any popular markdown processor.
  • You can always develop an extension to markdig in your own project if you really want this feature.
@xoofx commented on GitHub (May 25, 2018): > So, why was this closed? Are we saying this is already supported by "markdig advanced"? What is the solution that warrants closing this? - There is a already a way to define resize through attributes. - I don't see the value of adding a syntax that is not used by any popular markdown processor. - You can always develop an extension to markdig in your own project if you really want this feature.
Author
Owner

@MisinformedDNA commented on GitHub (May 29, 2018):

@seanmcilvenna The solution is this

![](http://example.com/image.jpg){width=250 height=120}

(which, ironically enough, isn't supported by any other popular markdown parser either.)

I'm still baffled that there is no widely accepted way of doing this.

@MisinformedDNA commented on GitHub (May 29, 2018): @seanmcilvenna The solution is this ``` ![](http://example.com/image.jpg){width=250 height=120} ``` (which, ironically enough, isn't supported by any other popular markdown parser either.) I'm still baffled that there is no widely accepted way of doing this.
Author
Owner

@seanmcilvenna commented on GitHub (May 29, 2018):

do you mean that this is currently supported by markdig?

@seanmcilvenna commented on GitHub (May 29, 2018): do you mean that this is currently supported by markdig?
Author
Owner

@xoofx commented on GitHub (May 29, 2018):

(which, ironically enough, isn't supported by any other popular markdown parser either.)

I'm still baffled that there is no widely accepted way of doing this.

It is supported by pandoc, which is quite a strong markdown parser in the markdown ecosystem. The extension attributes in markdig is directly inspired from it.

do you mean that this is currently supported by markdig?

What is supported is the attributes syntax, as described above

If you really want to have your proposed syntax for your projects, it should not be a huge burden for you to develop an extension or to replace entirely the way links are parsed in markdig.

@xoofx commented on GitHub (May 29, 2018): > (which, ironically enough, isn't supported by any other popular markdown parser either.) > > I'm still baffled that there is no widely accepted way of doing this. It is supported by pandoc, which is quite a strong markdown parser in the markdown ecosystem. The extension attributes in markdig is directly inspired from it. > do you mean that this is currently supported by markdig? What is supported is the attributes syntax, as described [above](https://github.com/lunet-io/markdig/issues/226#issuecomment-391947172) If you really want to have your proposed syntax for your projects, it should not be a huge burden for you to develop an extension or to replace entirely the way links are parsed in markdig.
Author
Owner

@MisinformedDNA commented on GitHub (May 29, 2018):

@seanmcilvenna Yes,

![](http://example.com/image.jpg){width=250 height=120}

is supported by markdig. It is an example of the attribute syntax @xoofx is pointing you too.

@MisinformedDNA commented on GitHub (May 29, 2018): @seanmcilvenna Yes, ```md ![](http://example.com/image.jpg){width=250 height=120} ``` is supported by markdig. It is an example of the attribute syntax @xoofx is pointing you too.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#206