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