You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
preview markdown file, image can not reload when modified with other tool #65258
preview a markdown file which contains png image, when I modify the image file with mspaint., the preview window does not refresh to show the new picture, even if I set another name and set back.
VS Code version: Code 1.30.0 (c6e592b, 2018-12-11T22:29:11.253Z)
OS version: Windows_NT x64 10.0.10240
System Info
Item
Value
CPUs
Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (4 x 3192)
I have a similar issue, if an external program modifies a markdown file, it won't reload even with the "refresh preview" menu item. To get it to refresh I had to modify the markdown file within code.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Actually considering this only has 3 upvotes since December 2018, let's wait to see if there is enough interest in it from the community. I don't think it would be all that trivial to get right
This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.
Feels more like a bug than a feature for me. The issue is that the image seems to get cached in memory permanently and cannot be refreshed. The refresh preview menu item should at least clear this cache, shouldn't be too hard to implement.
Reacted by Andrew W. Harn, Adam Tunnicliffe, Alexandre Mutel, Baruch Nissenbaum and Leonhard Gruenschloss
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
Same here,
The best solution would be to auto detect changed images and auto refresh.
Limiting to images in same workspace may reduce load on the change detection service, if that is the issue.
Another solution would be to refresh when the refresh command is activated.
At the moment only closing and re-openning the preview works..
IMHO the different behaviour between the "refresh" command and open-close looks like a bug.
Actually considering this only has 3 upvotes since December 2018, let's wait to see if there is enough interest in it from the community. I don't think it would be all that trivial to get right
I think (but I might be wrong) it shouldn't be that complex to implement:
The MarkdownEngine could be extended to return not only a string, but also a list of images with their src. It could also be extended to accept some cache information:
interfaceRenderOutput{html: string;containingImages: {src: string}[];}interfaceRenderContext{/** * Each image is identified by its "src". * By default, an image has cache key `0`. * If the cache key of an image increases between two render calls, * the image must be reloaded. */imageCacheKeyBySrc: Map</* src: */string,number>;}
...
classMarkdownEngine{
...
publicasyncrender(input: SkinnyTextDocument|string,context: RenderContext): Promise<RenderOutput>
...
}
containingImages is used by the MarkdownPreview instance to manage individual file system watchers using createFileSystemWatcher (only for relative images - the absolute file path would need to be computed there).
The MarkdownPreview then manages some imageCacheKeyBySrc map.
Whenever such a file system watchers triggers, the key of the watched image is increased and the preview is rerendered with the updated imageCacheKeyBySrc map.
The MarkdownEngine uses the image key to invalidate the cache. This is implemented by using a query parameter ala token.setAttr("src", `${src}&cacheKey=${imageCacheKeyBySrc.get(img.src) || 0}`).
This must not affect the reported src though.
However, this might conflict with the image size cache so one needs to be careful there.
Can you explain which problem the image size cache solves? I tried to disable the image size cache to see it's effect and created a document with many images loaded from https and things were still very smooth. It seems like the webview itself caches the size already.
What do you think? I'd submit a PR if you are fine with this approach! Thanks 😉
Activity
vscodebot commentedon Dec 18, 2018
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
FokkoVeegens commentedon Jan 29, 2019
I can confirm this.
Version: 1.30.2 (user setup)
Commit: 61122f8
Date: 2019-01-07T22:54:13.295Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 10.0.17134
Even when using the "Refresh Preview" functionality, it doesn't refresh externally changed images.

sbstp commentedon Feb 25, 2019
I have a similar issue, if an external program modifies a markdown file, it won't reload even with the "refresh preview" menu item. To get it to refresh I had to modify the markdown file within code.
tomasaschan commentedon Apr 20, 2020
This is tagged "help wanted", and I'd like to help solve it if I can. Are there any pointers/guesses on where the problem might lie?
vscode-triage-bot commentedon Apr 20, 2020
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
mjbvz commentedon Apr 20, 2020
Actually considering this only has 3 upvotes since December 2018, let's wait to see if there is enough interest in it from the community. I don't think it would be all that trivial to get right
vscode-triage-bot commentedon Jun 10, 2020
This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.
Happy Coding
sbstp commentedon Jun 10, 2020
Feels more like a bug than a feature for me. The issue is that the image seems to get cached in memory permanently and cannot be refreshed. The refresh preview menu item should at least clear this cache, shouldn't be too hard to implement.
vscode-triage-bot commentedon Jun 17, 2020
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
2 remaining items
qt1 commentedon Oct 27, 2020
Same here,
The best solution would be to auto detect changed images and auto refresh.
Limiting to images in same workspace may reduce load on the change detection service, if that is the issue.
Another solution would be to refresh when the refresh command is activated.
At the moment only closing and re-openning the preview works..
IMHO the different behaviour between the "refresh" command and open-close looks like a bug.
Thanks :)
hediet commentedon Jan 7, 2021
I think (but I might be wrong) it shouldn't be that complex to implement:
The
MarkdownEnginecould be extended to return not only a string, but also a list of images with theirsrc. It could also be extended to accept some cache information:containingImagesis used by theMarkdownPreviewinstance to manage individual file system watchers usingcreateFileSystemWatcher(only for relative images - the absolute file path would need to be computed there).The
MarkdownPreviewthen manages someimageCacheKeyBySrcmap.Whenever such a file system watchers triggers, the key of the watched image is increased and the preview is rerendered with the updated
imageCacheKeyBySrcmap.The
MarkdownEngineuses the image key to invalidate the cache. This is implemented by using a query parameter alatoken.setAttr("src", `${src}&cacheKey=${imageCacheKeyBySrc.get(img.src) || 0}`).This must not affect the reported
srcthough.However, this might conflict with the image size cache so one needs to be careful there.
Can you explain which problem the image size cache solves? I tried to disable the image size cache to see it's effect and created a document with many images loaded from
httpsand things were still very smooth. It seems like the webview itself caches the size already.What do you think? I'd submit a PR if you are fine with this approach! Thanks 😉
hediet commentedon Jan 9, 2021
With the risk of wasting time, I couldn't resist to implement it quickly:
I'll open a PR soon!
Refresh Images In Markdown Preview On Change (implements microsoft#65258
Refresh Images In Markdown Preview On Change (#114083)
isidorn commentedon Jan 26, 2021
Works great, nice work Henning Dieterichs (@hediet)
Adding verified label