@Dirk, during my morning meditation, your project popped into my head a few times. The inspiration I had is that I think you might want to consider a different approach to how you’re handling media in Tinderbox.
It is my hope that these ideas can inspire you and the rest of the community.
We reviewed much of this in today’s meetup (will get published by tomorrow). In the meetup, you’ll see I ran into a couple of snags near the end, most of which I’ve solved. The one item I’ve not solved is how to covert the HTML in an included image
Part 1: Where I Store Assets on My Hardrive
Don’t store media (e.g., images, audio, video) that you may want to reuse outside of an individual note; keep the image on your hard drive.
For me, this is very important. There is nothing wrong with pasting an image into a note. However, when doing so, I find it difficult to reuse the VERY VALUABLE ASSET, i.e., the image, elsewhere, i.e., across the TBX file of focus, across all TBX files, let alone in any other app or project that I am working on now or in the future.
My approach is to have a media directory on my hard drive. In this Media directory, I have sub directories for various types so of files: images for prices, images, videos, and audio files. Or, I have a media file in the specific hierarch of a project-specific file. NOTE: I’ve toyed with storing these images in DEVONthink, but the DEVONthink file path makes it nearly impossible to source the image back into Tinderbox (this is not a TBX issue, but rather DEVONThink; i can explain this later if you’re interested)
Again, why do I do this? To maintain optimal flexibility and reusability of my media assets.
Part 2: How I Manage Media in Tinderbox, Create a $Prototype for Media (pMedia)
My assumption, working model, is that the media note, e.g., an image, is one that I will want to reuse across projects. Moreover, I may want to do many things with it: include it with full resolution, include it with partial resolution, include a short reference (e.g., Figure 1), include a long reference (e.g., Figure 1: Tinderbox Logo), automatically renumber the captions based on their position in the outline and where or to they’re in an appendix or not, suppress the title, add citations to the captions, dynamically change the path (sometimes I move or copy the media asset from my generic assets folder to a project-specific folder once the project gets big enough to warrant this or if it is client specific and I need to maintain a record of the media in both places (generic or client).
In other words, for my future self to have the most flexibility, I break everything down into its attributes. At a minimum, in my media prototype ($Prototype=“pMedia”), I have the following attributes:
$ShortTitle (string)
$Type (set)
$MediaPath (string)
$MediaDir (string)
$MediaFileName (string)
$MediaHeight (string)
$MediaWidth (string)
$CaptionPrefix (set)
$CaptionLabel (set)
$CaptionNo (string)
$Caption (string)
$CrossRefShort (string)
$CrossRefLong (string)
$MediaPrefix (set)
$CaptionNote (string)
$CitationKey (string)
$Attribution (set)
$URL (URL)
$IsNoShowText (boolean)
$IsNotShowTitle (boolean)
$IsNoShowChild (boolean)
I maintain a TBXConfig file that holds the defaults to the genetic assets $MediaPath and $MediaDir on my hard drive; in my template, I have every note use these global values unless I override the local on an individual note.
Note: I won’t get into it here, but my media prototype enables me to be dynamic with all types of media, images, audio, and video (local or embedded from different providers). For now, I’ll stick to images; we can discuss the other media type handling later.
Part 3 Assemble my Notes with Templates and Includes
Now that my media is on a separate note, there are tons of things I can do. I can include them in the hierarchy of an outline and have them placed exactly where I want when I export. I can use '^incude()^ to insert them inline within a note $Text. I can $Cross reference them using ^include()^ across note $Text, and so much more. Also, I can output everything in HTML, Word, Markdown, or whatever output format I want.
Let’s stick with outputting to Markdown for this example.
I won’t explain all that I do here, but here is the high-level. I’ve been a lot of affordances for myself with the use of booleans. These allow me to suppress $Name, $Text, $Children, and other elements when exporting. Also, I’ve created an autonumbering scheme so that the root of a report starts at the selected note, and then headings cascade down from this root, rather than everything having to start from the root of the TBX file. These and several other treatments I use create a ton of flexibility, but we won’t go into this now. For now, let’s assume we have a single project at root. I’ve included some of the boolean ideas in the sample file here, but not the other ones.
TBX L - Markdown Text and Image Export.tbx (577.7 KB)
Note: there are ways to deal with the whitespace in the export. Also, I’ve tried to create a template that lets you process any export code you have in a note’s text and keep the output as pure markdown. It works up to a point. I ran into a snag where I needed to reformat a processed image. Right now, as you’ll see in the demo, in the case of an include in text, the image is HTML formatted and not markdown formatted. I don’t have the time today to resolve this bit. I will require some post-processing replacements.
Part 4 Move or Copy The Image to A Local Directory
I don’t have time today to go over this. But, if you need to move or copy the images from a general directory to a specific project directory, I’ve developed some command line scripts to do this.