1
0
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:
Jermolene
2014-06-12 08:36:30 +01:00
parent f131c37893
commit 9547a1f01c
8 changed files with 147 additions and 20 deletions

View File

@@ -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;
}
}
}
}