mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-16 07:17:21 +00:00
First pass at external image support
A bunch of little changes that together enable external image support. Try: ``` tiddlywiki editions/tw5.com --verbose --build externalimages ``` Then open `externalimages.html`, look for the images in the more/types tab of the sidebar, open them and verify that they are set with an external SRC attribute, not a data URI.
This commit is contained in:
@@ -56,20 +56,37 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||
} else {
|
||||
// Check if it is an image tiddler
|
||||
if(this.wiki.isImageTiddler(this.imageSource)) {
|
||||
// Render the appropriate element for the image type
|
||||
var type = tiddler.fields.type,
|
||||
text = tiddler.fields.text;
|
||||
switch(type) {
|
||||
case "application/pdf":
|
||||
tag = "embed";
|
||||
src = "data:application/pdf;base64," + text;
|
||||
break;
|
||||
case "image/svg+xml":
|
||||
src = "data:image/svg+xml," + encodeURIComponent(text);
|
||||
break;
|
||||
default:
|
||||
src = "data:" + type + ";base64," + text;
|
||||
break;
|
||||
text = tiddler.fields.text,
|
||||
_canonical_uri = tiddler.fields._canonical_uri;
|
||||
// If the tiddler has body text then it doesn't need to be lazily loaded
|
||||
if(text) {
|
||||
// Render the appropriate element for the image type
|
||||
switch(type) {
|
||||
case "application/pdf":
|
||||
tag = "embed";
|
||||
src = "data:application/pdf;base64," + text;
|
||||
break;
|
||||
case "image/svg+xml":
|
||||
src = "data:image/svg+xml," + encodeURIComponent(text);
|
||||
break;
|
||||
default:
|
||||
src = "data:" + type + ";base64," + text;
|
||||
break;
|
||||
}
|
||||
} else if(_canonical_uri) {
|
||||
switch(type) {
|
||||
case "application/pdf":
|
||||
tag = "embed";
|
||||
src = _canonical_uri;
|
||||
break;
|
||||
case "image/svg+xml":
|
||||
src = _canonical_uri;
|
||||
break;
|
||||
default:
|
||||
src = _canonical_uri;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user