Drag&Drop to get _canonical_uri of dragged photo?

110 views
Skip to first unread message

Gordan Nia

unread,
May 20, 2020, 11:16:38 AM5/20/20
to TiddlyWiki
Hello,

does it possible to get _canonical_uri value of external photo in a tiddler by drag&drop (or import as a tiddler with _canonical_uri)?    I don't want import photo as a new tiddler, but only reference to the photo (_canonical_uri).
How to make it, any idea?

Thanks,
Gordan

Mark S.

unread,
May 20, 2020, 11:51:55 AM5/20/20
to TiddlyWiki
I believe you can do something like this with the external file plugin on TiddlyDesktop.

The full file name and path is unavailable to the browser thanks to security precautions.

Michael Wiktowy

unread,
May 20, 2020, 11:58:33 AM5/20/20
to tiddl...@googlegroups.com
Hi Gordan,

I don't know of a generic built-in way but you can create a macro to have an area (the tag image in this case) defined as a droppable zone that generates a tiddler (transparently in the background ... look in Resent tab) for you when you drag a URL over and drop it on the area. The mime-type text/html seemed the most generic to handle most URLs that you'd drag over but it puts a big frame around the embedded stuff. You can change that to something more specific to allow TiddlyWiki to treat the external resource in a more integrated manner.

Just cut and paste the following into your own wiki and adapt as needed.

\define droppable-canonical()
<$fieldmangler tiddler=<<actionTiddler>>>
<$action-setfield $tiddler=<<actionTiddler>> $field="_canonical_uri" $value=<<actionTiddler>>/>
<$action-setfield $tiddler=<<actionTiddler>> $field="type" $value="text/
html"/>
</$fieldmangler>
\end
 
''Usage:'' This a small macro to add a droppable area in a tiddler to import externally dragged URLs into TiddlyWiki as a canonical-url externally stored resource.
 
Droppable Image (drag a URL on top of the image):
<$droppable actions=<<droppable-canonical>>>
{{$:/core/images/new-here-button}}
</$droppable>

Enjoy,
/Mike

Gordan Nia

unread,
May 20, 2020, 2:39:05 PM5/20/20
to TiddlyWiki
Thanks Mike!
That's good idea, it works! But, I have an additional question:

1) I don't want drag an URL of a photo, but the photo directly, e.g. sometning.jpg from desktop or a folder to TW in order to get the _canonical_uri in your way. What I have to change/add in your code? (I'm not an expert in that area).

Thank you very much!


Michael Wiktowy

unread,
May 20, 2020, 3:11:00 PM5/20/20
to TiddlyWiki
Unfortunately this has limits. As Mark pointed out, the browser blocks file:// type URLs. So your resources would need to be online somewhere.

/Mike

Mark S.

unread,
May 20, 2020, 3:37:40 PM5/20/20
to TiddlyWiki
To repeat, you can do this in TiddlyDesktop with the External Attachments Support plugin installed.

si

unread,
May 20, 2020, 5:29:20 PM5/20/20
to TiddlyWiki
Hi Mark,

Thanks for mentioning the External Attachments plugin - I didn't know it existed.

I tried it and it works for images but not for audio. Do you happen to know if there's anything I can do to get it working for audio?

Gordan Nia

unread,
May 20, 2020, 5:47:58 PM5/20/20
to tiddl...@googlegroups.com
Thanks everyone!

Regards,

Gordan

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/oGs8A1vxjOw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3f21a89e-3e58-41f3-be2e-1cef71af76eb%40googlegroups.com.


--

 GordaN

Mark S.

unread,
May 20, 2020, 6:09:52 PM5/20/20
to TiddlyWiki
I just tried it, and it worked for an MP3 file.

si

unread,
May 21, 2020, 7:08:34 AM5/21/20
to TiddlyWiki
Hmm that's weird. I tried dragging and dropping an mp3 file and it just gets imported into the wiki as it would without the plugin. Whereas when I do the exact same thing with png it creates a _canonical_uri tiddler.

This is all on a freshly downloaded empty wiki, with only the External Attachments plugin installed.

Do you mind if ask which OS you are using TiddlyDesktop with? I've tried it on both 32 and 64 bit Windows.
Reply all
Reply to author
Forward
0 new messages