Ghost: Set "title" attribute for images from markdown

Created on 8 Oct 2013  路  7Comments  路  Source: TryGhost/Ghost

It'd be nice if we could set the title attribute for images as well as the alt attribute with the caption being entered in the markdown.

editor

Most helpful comment

Regarding the title: I propose to use

<figure>
  <img src=".." alt=".." title="Optional title" />
  <figcaption>Optional title</figcaption>
</figure>

This would make it easy to add captions to images that are easy to style with CSS.

@JohnONolan This isn't a Markdown extension. It's part of the original Markdown: http://daringfireball.net/projects/markdown/syntax#img


I'd like to implement this if above format is accepted.

All 7 comments

I agree - this is a markdown extension, however, and as such extremely complicated to implement at present.

At the moment, we're using showdown for markdown to html conversion. Showdown uses regular expressions, which gets us into all kinds of knots. I had to take out title support in order to have better URL support. At the moment, it's a trade-off. In the future we'll use a proper parser, and be able to handle advanced features such as this.

Regarding the title: I propose to use

<figure>
  <img src=".." alt=".." title="Optional title" />
  <figcaption>Optional title</figcaption>
</figure>

This would make it easy to add captions to images that are easy to style with CSS.

@JohnONolan This isn't a Markdown extension. It's part of the original Markdown: http://daringfireball.net/projects/markdown/syntax#img


I'd like to implement this if above format is accepted.

@halfdan looks good...

Would this result in this for no title?

<figure>
    <img src=".." alt=".." title="Optional title" />
</figure>

or simple:

<img src=".." alt=".." />

@Fasani: I guess to be consistent it should also result in <figure />, but I let @JohnONolan decide on that.

Creating functionality like this is a lot less to do with what is and isn't a formal Markdown extension (you're right, it is) and a lot more to do with what is and isn't an extension of the Markdown-parsing-functionality which we have available to us (in which context, it absolutely is).

We plan to rip out the guts of our current Markdown parsing implementation (which is hack++) and write our own engine, as this is obviously a very integral/core part of Ghost.

Until then, as @ErisDS mentions, we heard you like REGEX so we put some REGEX in ur REGEX. ;) Which is not an ideal starting point for extending into more complex functionality.

Enhancements like this are absolutely welcome - we're just not quite ready for them yet.

Closing as wontfix against #1294 as it's pretty hard to get done before we rebuild the editor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RadoslavGatev picture RadoslavGatev  路  3Comments

krokofant picture krokofant  路  3Comments

hjzheng picture hjzheng  路  4Comments

jaguart picture jaguart  路  3Comments

jliikala picture jliikala  路  3Comments