> believe there are several slightly different formats floating, some > TiddlyWeb makes a tiddler with binary content have a text field of the > full data uri of the content: > data:image/png;base64,iVBORw0K...
> The idea being that this could then be paired with an extension to the > wikifier which knows how to handle data uris (e.g. in the case of a > type of image/* it would make an image tag with the entire data uri as > the src; for non-image/* it would make an href). > All of these have, amongst other issues, a similar problem: If the > tiddler is opened for edit it is far too easy to corrupt the data. When I first created binary attachments years ago, there wasn't any core support for slices, sections, or fields. I created my own 'embedded marker' syntax, combined with string parsing, to extract the stored data URI value from the tiddler. Although this approach worked well, I was never really happy with it, as it was a custom solution with "brittle" syntax and also had more formatting overhead than I prefer. As a result, I re-wrote the plugin early this year, so that the format for attachment tiddlers now only uses native TW syntax... specifically, tiddler sections. The format for an attachment tiddler is currently: -------------------------- !usage ... optional content ... !notes ... optional content ... !type image/gif !file ./images/filename.gif !url http://www.example.com/images/filename.gif !data data:image/gif;base64,R0lGODlhOABQAPcA... -------------------------- Any or all of these sections may be omitted from a given attachment. Only the !data, !file and !url sections (in that order), are used to access actual binary content. The !type, !notes, and !usage section are typically included for additional user-readable information. Note that the !data section occurs last, in order to avoid scrolling through a large block of encoded content in order to get to something editable. Of course, as you've noted, the encoded data *is* still editable, which would almost certainly render it unviewable. Nonetheless, by including it as fully-accessible content, it makes it possible to paste the binary into the tiddler data from other sources, such as by copying base64-encoded content attached to emails. Also note that the !data section is a complete data: URI, including MIME type. This makes it really easy to use the URI without needed *any* special plugin code at all... For example: to use the URI as a background image in a CSS statement, you can write something like this in StyleSheet: body { background-image: url([[AttachmentName##data]]); } The core takes care of extracting the value from the section, and inserts it into the CSS *before* handing it off to the browser for processing. You can also render the data: URI as an embedded image, using a little bit of TW-native syntax, like this: /% !show $1 !end %/<<tiddler {{tiddler.title+"##show"}} with: {{store.getTiddlerText("AttachmentName##data")}}>> ... and, if you have AttachFilePluginFormatters installed, then you can simply write: [img[AttachmentName]] and the plugin will do the rest, including selecting amonst the three- tiered fallback: data (if present, and not IE), otherwise local file (if found), otherwise remote URL. enjoy, -e --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/tiddlywikidev?hl=en -~----------~----~----~----~------~----~------~--~---
