Id attribute on images not working

Hi, there. Just thought I would mention that this markdown is not working:

![](somephoto.jpg?id=some-photo)

It produces an img tag with no id attribute at all, but also without ‘?id=some-photo’ appended to the img src as a query string (so it is being processed to some extent). Classes work fine. I am using v1.1.1

On a side note, the text area here in the forum posting box has the cursor set to ‘pointer’ in the css (like a link pointer), which makes it hard to edit. File is moot.css under rule ‘.m-input-wrap textarea’.

Thanks.

Never tried to output an id but I remember having to enable markdown extra for classes to be outputted. So, maybe make sure that markdown extra is enabled in your site configuration

Shouldn’t need markdown extra. i have tests running to ensure this id is working, and it’s not failing: https://github.com/getgrav/grav/blob/develop/tests/unit/Grav/Common/Markdown/ParsedownTest.php#L654-L661

Could it be the - that is causing the issue?

I have tried it without the hyphen and it makes no difference. Interestingly, when I enable markdown extra and try it with their syntax:

![](somephoto.jpg){#somephotoid}
or
![](somephoto.jpg){.somephotoclass}

I get the same behavior: classes work, id’s don’t.

I was looking at some of the source code. In ParsedownGravTrait.php, in the function ‘inlineImage’, if I dump the variable ‘$excerpt’ near the beginning, after the first if-else block (say line 205), I get the following:

array:2 [▼
  "extent" => 60
  "element" => array:2 [▼
    "name" => "img"
    "attributes" => array:5 [▼
      "src" => "/grav-site/about-me/ArtistPhoto2.jpg"
      "alt" => "Indrani Choudhury"
      "title" => null
      "id" => "indr"
      "class" => "indrani-photo"
    ]
  ]
]

It remains the same until on line 267 there is the following call:
—php
$excerpt[‘element’] = $medium->parseDownElement($title, $alt, $class, true);

After that $excerpt looks like this:

array:2 [▼
"extent" => 60
"element" => array:2 [▼
"name" => “img”
“attributes” => array:3 [▼
"alt" => “Indrani Choudhury”
“class” => “indrani-photo”
“src” => “/grav-site/user/pages/02.about-me/ArtistPhoto2.jpg”
]
]
]

This seems to be where the id is being lost.  It is not being passed along.  Am I missing something?

I just tried it on clean installs, versions 1.1.1 and 1.0.10, and got the same problem.

Please create an issue for this in the Grav issue tracker.

OK, I just did, thanks. Btw, the unit test you linked above only checks links, not img’s.

Ah, ok, i will expand our tests to cover id on images too, and i’ll dig into this further on monday.