Do not transform URIs of online images.
This commit is contained in:
parent
c647d7d86b
commit
f86534985b
|
@ -188,10 +188,10 @@
|
|||
"default": false,
|
||||
"description": "Suppress warnings."
|
||||
},
|
||||
"texinfo.preview.displayImage": {
|
||||
"texinfo.preview.localImage": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Display images in in preview."
|
||||
"description": "Display local images in in preview."
|
||||
},
|
||||
"texinfo.preview.customCSS": {
|
||||
"type": "string",
|
||||
|
|
|
@ -79,9 +79,11 @@ export default class PreviewContext {
|
|||
private pendingUpdate = false;
|
||||
|
||||
private get imageTransformer(): Optional<Operator<string>> {
|
||||
if (!Options.displayImage) return undefined;
|
||||
if (!Options.localImage) return undefined;
|
||||
const pathName = path.dirname(this.document.fileName);
|
||||
return src => {
|
||||
// Do not transform URIs of online images.
|
||||
if (src.startsWith('https://') || src.startsWith('http://')) return src;
|
||||
const srcUri = vscode.Uri.file(pathName + '/' + src);
|
||||
// To display images in webviews, image URIs in HTML should be converted to VSCode-recognizable ones.
|
||||
return this.panel.webview.asWebviewUri(srcUri).toString();
|
||||
|
|
|
@ -70,8 +70,8 @@ export default class Options implements vscode.Disposable {
|
|||
return Options.instance.getBoolean('preview.noWarnings');
|
||||
}
|
||||
|
||||
static get displayImage() {
|
||||
return Options.instance.getBoolean('preview.displayImage');
|
||||
static get localImage() {
|
||||
return Options.instance.getBoolean('preview.localImage');
|
||||
}
|
||||
|
||||
static get customCSS() {
|
||||
|
|
Loading…
Reference in New Issue