Markdown syntax -- how to adding title to image

markdown

(Justin Gordon) #1

What is the discourse markdown syntax to add a title to an image?


(Mittineague) #3

I recenently asked in another topic but the question hasn’t been answered yet.


(Justin Gordon) #4

I was actually looking for how to do the lightbox title.


(Sam Saffron) #5

@zogstrip do we have provisions for this, what happens if you enter the image tag manually and set title ?


(Jeff Atwood) #6

Why, adding title already works with existing Markdown syntax.

http://superuser.com/editing-help#images


(Justin Gordon) #7

That title is just a mouseover. I don’t think it would work on mobile.

I’m interested in placing a static title under each picture here:


(Régis Hanol) #8

It works as expected :wink:


(Benjamin Kampmann) #9

I know some text-pre-processors have support for image labeling, but then again, markdown isn’t Latex on purpose.

What I am currently thinking is that this could easily be a (JS) plugin, which reads the “title”-tag of an image in the cooked-data and wrap each one into the appropriate <figure><figcaption></figcaption></figure>-tags. Then throw some CSS as it to make it look pretty and there you go.


That said. Can’t we already do this even? Here is what this

<figure><img src='//discourse-meta.s3-us-west-1.amazonaws.com/original/2X/3/39239a7f2b0f0aa72bdd0d3c1880f15f1a967276.png'><figcaption>The discourse logo</figcaption></figure>

looks like rendered:

The discourse logo

look at that. HTML5 is just awesome.


(Rahul Dhingra) #10

Is there any way to add caption to “pasted image” ? I tried “title” & “alt” tags but nothing works


(Jeff Atwood) #11

The only way at the moment is to not paste, but upload a file (or drag and drop) – the filename will be displayed. Like so:

Pasted images will always say “pasted image”, but uploaded or drag-n-drop files will show the filename in the lightbox.


(Christoph) #14

I realized that using <figcaption> in a post doesn’t render properly (the caption appears next to instead of under the image, like this:

The reson for this is that the figcaption tags seem to be simply stripped away:

So I’m guessing this has something to to with it not being whitelisted?

Is there any risk whith whitelisting that tag? Would be great to be able to use it.


(Christoph) #15

Just to be clear: what I meant was “could the tag please be whitelisted by default in discourse core?”

If I can do this myself on my instance, I’d appreciate some hints about how to do it :slightly_smiling_face:


(Jeff Atwood) #16

Markdown syntax is now used for images as of Discourse 1.9 as I recall… refer to http://commonmark.org/help

![kanye-west-crazy-eye|361x500](upload://ciOh12NkCh4K76Ogc2ypZOg54ov.jpg)

The original filename was indeed kanye-west-crazy-eye.jpg, but we should see an effect from editing to

![YOUR TEXT HERE|361x500](upload://ciOh12NkCh4K76Ogc2ypZOg54ov.jpg)

cc @sam


(Jeff Atwood) #17

Let me try this:

![Logo][1]

[1]: //discourse-meta.s3-us-west-1.amazonaws.com/original/3X/f/7/f7a6164ffa55af4ee2706d2386227183ef6c2d61.png "Creative Commons licensed"

Logo

That works because it’s a small (and remote) image that is not lightboxed, though.


(Christoph) #18

From what I can see, CommonMark currently doesn’t support image captions. At least it’s not in the specs at spec.commonmark.org. And previous discussions about the feature seem to have been inconclusive:

So I guess we still need the html tag…