Suggestion regarding images...

19 views
Skip to first unread message

Ashy

unread,
Apr 20, 2006, 12:06:44 PM4/20/06
to TiddlyWiki
Currently, Tiddlywiki has the capability to define a local folder for
backups. Could the same thing be done for defining a local folder for
images when running Tiddlywiki locally, except that it would work as a
var in the paths of your images? This way, when you run locally, all
of your images would display (provided they were in the proper folder).
Also, could the same thing be done for running online, say if you
uploaded all of your images to http://www.mywebsite.com/imgs/ - if so,
you could toggle your Tiddlywiki back and forth depending on how you
were using it and still have access to all your images...

Just some thoughts.
Brannon "Ashy" Hollingsworth

El noi

unread,
Apr 20, 2006, 12:33:23 PM4/20/06
to TiddlyWiki
Great!
In addition: the information of the folder would not be stored in a
cookie

Ashy

unread,
Apr 20, 2006, 12:51:09 PM4/20/06
to TiddlyWiki
Please bear in mind that I'm NOT signing up to implement this (I
wouldn't know how), but just suggesting it as a possibility of
inclusion into TW... :)

Brannon "Ashy" Hollingsworth

Daniel Baird

unread,
Apr 20, 2006, 6:27:21 PM4/20/06
to Tiddl...@googlegroups.com

I'm likely to implement an image including macro in the next few weeks -- I need it for a documentation project I'm working on.  I'm thinking of something like <<img JanetJacksonsNipple.jpg>> and it prepends some path to the start.  Maybe even have two different paths depending whether the URL is file:// or not.

I might even have a location like this:
<<img local MrT.jpg>>
<<img flickr orly.jpg>>
..and let you specify different prefixes etc for the locations "local" and "flickr".

Sound like what you want?

;Daniel
--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things That Suck)
[[My webhost uptime is ~ 92%.. if no answer pls call again later!]]

Udo Borkowski

unread,
Apr 21, 2006, 2:39:43 AM4/21/06
to Tiddl...@googlegroups.com
Sounds good to me, at least.

Maybe also allow size specification and the other img attibutes. The new parseParams function should make that easy.

Udo

Jules

unread,
Apr 21, 2006, 3:10:51 AM4/21/06
to TiddlyWiki
Nice, would be even nicer if you could do embeded images too!! A
command to load an image into a tiddler (perhaps with warnings on image
size) and an extension to your macro - something like:

<<img embed small.jpg>>

And with Udo's suggestion:

<<img embed small.jpg 50 45>>

or whatever.

--
Jules
www.knightnet.org.uk
http://knighjm.googlepages.com/knightnet-default-tw.html

Udo Borkowski

unread,
Apr 21, 2006, 3:21:55 AM4/21/06
to Tiddl...@googlegroups.com
For the optional parameters I would suggest the "named arguments" feature:

<<img small.jpg width: 50 height: 45>>


Udo

Daniel Baird

unread,
Apr 21, 2006, 5:42:55 AM4/21/06
to Tiddl...@googlegroups.com

Jules, last time this came up, you either had to a) use a data:// url, which doesn't work in IE, or b) trick up the image with a bunch of 1 pixel divs of various colours.

Do you know a trick to actually embed images?  I'm hoping you've come across some better plan..

;D

Jules

unread,
Apr 21, 2006, 10:19:46 AM4/21/06
to TiddlyWiki
Sorry Daniel, I don't know of anything specific.

However (he says to a sound of grinding gears) - it might be possible
to trick something up with a base64 (or similar) de/en-coding tool.
This is basically how its done in MIME encoded emails with embeded
images.

What would be needed would be a tool to encode the image to ASCII
(that's what Base64 does). And some JavaScript to do an on-the-fly
decode and insert into the DOM.

However, I've just gone well beyond my own actual knowledge of what can
be done, maybe someone with better JS skills will get some ideas from
this?

It must be possible in some way since it works fine in my email
clients.

Eric Shulman

unread,
Apr 21, 2006, 10:41:53 AM4/21/06
to TiddlyWiki
> However (he says to a sound of grinding gears) - it might be possible
> to trick something up with a base64 (or similar) de/en-coding tool.
> This is basically how its done in MIME encoded emails with embeded
> images.
>
> What would be needed would be a tool to encode the image to ASCII
> (that's what Base64 does). And some JavaScript to do an on-the-fly
> decode and insert into the DOM.

http://www.TiddlyTools.com/#AttachFilePlugin

converts binary file to base64
puts base64 in a tiddler tagged with "attachment"
extends wiki images and links to recognize references to attachment
tiddlers to render the image or create an 'external link' to the
attached binary.

Note: this Plugin works for FF only, as it uses the data: URI, which is
not supported on IE

enjoy,

-e
Eric Shulman
TiddlyTools / ELS Design Studios

Ashy

unread,
Apr 21, 2006, 2:51:24 PM4/21/06
to TiddlyWiki
Sounds about like it, yes!!! :)

Jules

unread,
Apr 21, 2006, 4:16:58 PM4/21/06
to TiddlyWiki
Ah ha, I knew I'd seen something.

Is the data: URI just for reading in the data?
If it is, I guess you could process the file externally?

It would be great to get this working for everyone.

Reply

Daniel Baird

unread,
Apr 21, 2006, 11:14:40 PM4/21/06
to Tiddl...@googlegroups.com

Yeah you have to provide the browser with a gif file somehow -- in Firefox you can give it a data:// url where the url itself is the encoded file content.

Unfortunately doens't work in IE, and there's no IE equivalent.

You know, we already write out the HTML file to the local machine.. I wonder if it's possible to actually write out the image file to the local drive, and link to it there?  Hmm..

;D

Ashy

unread,
Apr 26, 2006, 12:20:00 PM4/26/06
to TiddlyWiki
Yea, I've kinda given up on actually encoding the image file - that is
not really feasible. What I was talking about was a simple (if not
unelegant) workaround. :P So, is anyone out there working on this now
or shall it remain a pipedream? :)

Brannon "Ashy" Hollingsworth
http://www.wowweezowwee.com

Eric Shulman

unread,
May 17, 2006, 6:14:47 PM5/17/06
to TiddlyWiki
Ashy wrote:
> Yea, I've kinda given up on actually encoding the image file - that is
> not really feasible. What I was talking about was a simple (if not
> unelegant) workaround. :P So, is anyone out there working on this now
> or shall it remain a pipedream? :)

UPDATE: http://www.TiddlyTools.com/#AttachFilePlugin

Now with the ability to store binary file content in three different
locations:

1) embedded in the attachment tiddler (encoded as base64)
2) on your filesystem (a 'local link' path/filename)
3) on a web server (a 'remote link' URL)

Regardless of the source of the binary content, the plugin creates an
"attachment tiddler" for each file you attach. These tiddlers can then
be used in place of a direct file or URL reference in your embedded
image or external links:

[img[tooltip|AttachmentTitle]]
or
[[display this text|AttachmentTitle]]

With embedded data, your TW document can be completely
self-contained... but only when using FireFox (IE can't handle
"data://"). However, an attachment tiddler can define several
locations at the same time: if the binary data doesn't exist in one
place, then the plugin tries the next one. If you define an attachment
with *both* embedded data and a 'local link' and then copy the
appropriate files to your local filesystem, IE will be able to show the
same binary content as FireFox, albeit from a different storage
location.

The "fallback" approach also lets you 'virtualize' the location very
large binary content such as PDFs, MP3's, and even *video* files, by
using just a 'remote reference link' without embedding any data or
downloading huge files to your hard disk. Of course, if you DO
download an attached file, the plugin will use the local copy instead
of accessing the server each time, thereby saving bandwidth and
allowing you to 'go mobile' without having to edit any tiddlers to
change the link locations...

Lastly, though not completed (but nearly there), the plugin includes an
integrated 'uploader' that will let you create a 'remote link'
attachment tiddler AND transfer the local file to a remote server
location in the same step!

Daniel Baird

unread,
May 17, 2006, 7:41:19 PM5/17/06
to Tiddl...@googlegroups.com

Eric, do you think it would be possible to have (small, I guess) images stored internally as base64, and when the TW is loaded, to take the following steps:

* when opened, check to see if you're running a browser that supports data:// URLs, and if so, use that for referring to images
* otherwise, check to see if there is a "twTempCachedImages" directory
** if dir doesn't exist, create it and write out the base64 image data as image files into that dir
** subsequently use relative URLs to get images out of that dir
* optionally, remove the dir and files when the TW is closed

You'd have to have your own image including macro like <<img whatever.jpg>> that output the right kind of html depending on the browser.

That way, a single file TW with images would stay a single-file for Firefox, but magically create the necessary images as external files as necessary for use with IE.

Wotcha think?  At first blush it seems like it should be possible..

;Daniel


Eric Shulman

unread,
May 17, 2006, 8:13:31 PM5/17/06
to TiddlyWiki
> Eric, do you think it would be possible to have (small, I guess) images
> stored internally as base64, and when the TW is loaded, to take the
> following steps:
>
> * when opened, check to see if you're running a browser that supports
> data:// URLs, and if so, use that for referring to images
> * otherwise, check to see if there is a "twTempCachedImages" directory
> ** if dir doesn't exist, create it and write out the base64 image data as
> image files into that dir
> ** subsequently use relative URLs to get images out of that dir
> * optionally, remove the dir and files when the TW is closed

While not exactly like the 'automatic cached image directory' you
suggest, I do have plans for putting a "detach" button into each
attachment tiddler:

This button will let you decode the attached base64 back into binary
content and then prompts for a path/file and writes the binary to that
file. It will then update the attachment tiddler's 'local link' to
reflect where you placed the file on your local drive.

-e

Daniel Baird

unread,
May 17, 2006, 8:25:59 PM5/17/06
to Tiddl...@googlegroups.com
On 5/18/06, Eric Shulman <elsd...@gmail.com> wrote:

While not exactly like the 'automatic cached image directory' you
suggest, I do have plans for putting a "detach" button into each
attachment tiddler:

This button will let you decode the attached base64 back into binary
content and then prompts for a path/file and writes the binary to that
file.  It will then update the attachment tiddler's 'local link' to
reflect where you placed the file on your local drive.

I was mainly thinking about using it for "site" stuff like little icons, backgrounds, etc.. so it would have to be done automatically.

I might make some time to look through your code, maybe get a jump start on getting something like that going :)

Cheers

;Daniel

--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things That Suck)
Reply all
Reply to author
Forward
0 new messages