Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add class in image markdown in Ghost?

In Ghost, the markdown for image is

![alt](src)

Is there a hidden format for adding a class in the img tag? Or is this feature not in Ghost yet?

I wanted to have a result like this:

<img src="src" alt="alt" class="img-thumbnail">

I don't want to use the html markup. I really need to achieve this using markdown. Please help..

like image 296
Melvin Avatar asked Mar 25 '14 07:03

Melvin


2 Answers

In plain markdown classes for images are not possible. In some implementations it is possible, e.g. markdown extra uses ![alt](src) {.class}. I tried it, but in Ghost it is not possible, neither ![alt|img-thumbnail](src). Also no hints in the doku.

But you can use a workaround:

If you use the src as css-attribute!

Just add an 'useless' hash to the URL:

![alt](src#img-thumbnail)

Then you can address this in CSS or JavaScript:

img[src$='#img-thumbnail'] { float:left;}

like image 143
klml Avatar answered Sep 16 '22 23:09

klml


this is perhaps too obvious but you can put it in any element you wish i.e.

 <div class="myDiv">
    ![](...)
 </div>

and then use css inheritance

.myDiv img { width: 50px; }

since markup in ghost supports html (probably most do) you can also do regular <img...> tags as well

like image 32
Sonic Soul Avatar answered Sep 17 '22 23:09

Sonic Soul