Closed ylc395 closed 2 years ago
@ylc395 alt text only displays when an image can't be rendered, hence the name alt (from "alternative"). This is a standard part of html/markdown.
I think maybe what you want is to set the hover text? This is called a title and it is available in markdown as follows:
![this is alt text](:/06f049df282b4780bbfbdc306383bab5 "I'm a title")
Please let me know if I was wrong about your question and I'll gladly re-open. I look forward to seeing your plugin!
@CalebJohn Yes, alt text is only displayed when image can not be loaded. But what I said is rendered-HTML doesn't cantain alt attribute at all, which means this is alt text
is totally lost in rendered-HTML.
Thanks for the clarification @ylc395
Looks like the alt text is preserved when the image is not available, so it performs in the way it should for that case. But indeed it's odd that the alt text isn't transferred to the html and leave the rendering to the actual HTML display.
The best next step would be to post about this on the forum, that will put the issue in front of the community and perhaps someone that knows more about the MD to HTML system will be able to chime in if this is beneficial or not.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.
Not stale.
Hey there @CalebJohn , Can I want to work on this issue ?
Go for it @mak2002, good luck!
hey @CalebJohn I was following this markdown-it issue about alt text and modified a JSFiddle provided there. Can you suggest how we can use this code to fix this issue?
I'm pretty sure Joplin overrides the default rule for images (somewhere here https://github.com/laurent22/joplin/tree/dev/packages/renderer/MdToHtml/rules) and this is where you should be looking.
Thanks @roman-r-m I will look into it and keep you updated with progress.
Hey @roman-r-m I was thinking maybe this issue is caused by putting this (:/06f049df282b4780bbfbdc306383bab5)
into the editor because when I tried by putting actual address like this: ![alt-text](/path/to/file/image.png)
it works this way. So maybe we can put the actual address of file in editor instead of (:/06f049df282b4780bbfbdc306383bab5)
while importing the image.
Hey @roman-r-m I was thinking maybe this issue is caused by putting this
(:/06f049df282b4780bbfbdc306383bab5)
into the editor because when I tried by putting actual address like this:![alt-text](/path/to/file/image.png)
it works this way. So maybe we can put the actual address of file in editor instead of(:/06f049df282b4780bbfbdc306383bab5)
while importing the image.
We can not put the actual path - there's a reason Joplin uses resource IDs there.
Namely - if you sync such note to another OS, the path will most likely be incorrect, e.g. on Linux it's ~/.config/joplin-desktop
and on Windows - %USERPROFILE%\.config\joplin-desktop
ohhk got it. Thanks for clarification @roman-r-m
hey @roman-r-m I think I have fixed this issue by getting alt text like: const alt = token.content;
and inserting it in img html: return <img data-from-md ${htmlUtils.attributesHtml(Object.assign({}, r, { title: title, alt: alt}))}${js}/>
;. So should I open a pull request or you want to suggest something?
Did you test it?
Yes @roman-r-m I tested it.
Well it'd be good to see some results.
You'll need to include them in the PR anyway (I assume you have read the contributor's guide)
@roman-r-m Yes I have read contributor's guide and soon will make a PR including the results.
Its renderring result won't contain alt text. Is it a bug or intended feature? In fact, I''m a plugin developer and want to store some information as images' alt text. It would be better if alt text won't be ignored.