Tracking Images in Scrivener for Blogging

Background

The goal is to prepare MMD formatted text that is heavily integrated with large numbers of images and publish to a blog in HTML format. I very much want to use Scrivener as a research / writing support tool but I’m struggling to achieve successful image management.

Blogging Process

My method for blog publishing content prepared in Scrivener is as follows:

  • write merrily in Scrivener
  • prepare diagrams in OmniGraffle and images in Acorn.
  • Use screen capture utility ( mostly SnapzProX ) to take snapshots of the areas that I want, and size them correctly. Then save these images to a directory on my computer.
  • Drag these snapshots, or other images into scrivener.
  • write more merrily in Scrivener.
  • Finish with a sense of gratitude.
  • Export the file to a RTFD file.
  • Open the RTFD in TextEdit.
  • Select all text and Copy to MarsEdit.
  • Select each image and drag it into MarsEdit, the image upload utility will then upload it to my wordpress and insert the appropriate HTML into MarsEdit window.
  • Repeat until all images are copied across and uploaded.
  • A final proofread in MarsEdit and press send.
  • then some sundry Wordpress munging occurs.

Problem - Image Handling

When I have a large number of images, they are positioned are relevant points within the document. Thus when I drag from TextEdit into MarsEdit I have to take a lot of care to precisely locate the images.

I notice that there is an import image function, and I’m wondering if there is some method to create a tag or note about the image filename when it is imported. The goal is to place a marker in the text to show some data about the image so I can reference the image file it more easily when I perform the copy into MarsEdit.

The Question

Is this possible ? Is there are method to automatically insert a tag reference to an image when I insert or drag an image into Scrivener ?

Or have I missed something in my workflow that would be smarter for blogging into HTML format that includes uploading the images to Wordpress ?

I look forward to hearing back from you.

There are two helpful things that Scrivener does when working with images and MMD.

  1. It will export all image resources (either embedded, linked, or Scriv Linked by name) into an export folder when you compile. The result would be to have your HTML file in a folder along with all of the graphics you assembled for the blog post.
  2. If the images are in the text files themselves, as opposed to just using MMD’s image syntax, then Scrivener will create MMD syntax for you, and subsequently convert that to HTML when you compile.

The end result is an HTML file that is all pre-linked to the graphics you need, but in this case they are probably not going to be linked to the right spot since you need their web addresses, and not the relative “same directory” links that Scrivener will use by default:

<img src="img.jpg" alt="" />

This will not work in WordPress. You probably need something more like:

<img src="/blog/media/img.jpg" alt="" />

Or:

<img src="http://www.yoursite.com/blog/media/img.jpg" alt="" />

There are a few ways this problem could be approached, but I’ll outline an easier one. What I would do—and what I have done in this precise circumstance before—is to largely ignore WordPress’s image upload tool as I find that to be inefficient (by proxy, this is probably more efficient with MarsEdit, but still I’d rather handle the images directly). What I do for most of my screenshots is use a program called Skitch, which is another screenshot application that has a handy upload facility. By default it uploads to their social network, but you can easily change this to work with your own FTP server, where the WordPress installation is, you can even give it the right folder that they should be uploaded to. SnapzProX might have a similar facility if you poke around. What Skitch does is let me put the entire URL into the clipboard after it uploads. So as I’m composing the MMD document, I just type in:

![Alt text](

And then paste in the URL it gives me, closing off the parenthesis or supplying a title, like:

![Alt text](http://www.something.com/img.jpg "The title of the image")

So while I’m not exactly sure if that is what you mean by automatically tagging images when you import them, but if you do mean inserting appropriate HTML code in place of the image—then yes, that is something that can be done, and without any work on your part except for changing the compiler to one of the MMD compilers instead of RTFD.

That leaves images I haven’t snapped. For those I just use a regular FTP program. I use YummyFTP for this, and set up a droplet so I can just drop image files onto it and it will handle connecting to the server and uploading the images to the correct location. In that case, I need to get the URLs myself, but YummyFTP has an easy way of doing this. I just right-click on the file in the FTP browser and grab the web URL to the clipboard then follow the above instructions.

So that is how I approach it. When it comes time to publish to WordPress, I don’t use the rich edit mode, but switch over to HTML and just paste the MMD produced XHTML right into the program. When you do this, you want to only paste what is inside the [b]body[/b] element.

Now, that’s because I don’t use MarsEdit or any helpers. I pretty much do everything the “manual” way because frankly I find that easier than trying to coerce programs that promise “easy” into doing what I want. So I have less advice on how to integrate with MarsEdit on this score.

But at the very least if you compile out of Scrivener as MultiMarkdown -> HTML, you should get all of the images you used automatically collected into this compile folder for you, which should speed up that part of the process. Maybe MarsEdit even has a feature where you can import an HTML file and it will include all referenced images? If not that, it surely has the capacity to handle HTML imports rather than just pasting RTFD data I hope.

A more complicated solution would be to write a simple wrapper XSLT that processes XHTML back into XHTML, but only after fixing a few things, like adding the prefix part to the path of the images. Using a method like this, you could just upload your images using whatever mechanism you prefer (MarsEdit; snapshot program; FTP client) and then compile out of Scrivener to MMD->HTML with no edits. Leaving “Format: complete” off of the default meta-data list (that’s set in Compile), will also negate the need for only selecting the stuff inside of the [b]body[/b] element, as it will only generate a “snippet” XHTML file, rather than a full valid web page.

Thanks for your excellent response, AmberV.

The problem with direct upload for me, is that it bypasses two very useful features in Wordpress. One is the automated image resizing that creates four different sizes when a file is uploaded. With this different sizes you can create fancybox ‘growing’ images from thumb to full size. That’s useful for certain diagrams that fit on the page, and readers can click to expand to the full size. Plus it creates the automatic thumbnails that I use for the featured image and the smaller sizes can also form nice context when aligned left and right.

Second, I have a plugin that compresses the uploaded images (without losing quality) for smaller and faster download. This is important for my hosting bill, and also for page speed for SEO ranking.

Therefore the uploading of images via the XML-RPC is quite neat and MarsEdit does this nicely plus helps with a preview capability. It’s a big improvement over the Wordpress uploader for sure (and it also has offline upload scheduling) . And I agree, Skitch is a great little image editor, but not useful as an uploading tool because it bypasses the image resize.

What I’m hoping for is that when I drag an image into Scrivener, or Import the Image, that there is some meta data that would appear with the image. Just the file name would be useful enough as a title for image. That would give me a ‘hook’ on where the image was located in the text.

Does that make sense ?

Yeah, that makes perfect sense, which goes back to my explanation of using MMD to do the compile, rather than compiling as RTFD and pasting it into MarsEdit (sorry, that got a bit lost in the description of my own manually derived methods). The advantage is that Scrivener will inject the filename into the document and extract all of the images you used into files right in that compile folder. So you can process them all easily with MarsEdit since they are all gathered together and ready for your tool to convert to thumbnails and etc.

Here is the basic idea:

You compile out of Scrivener using “MultiMarkdown”. This creates a file like this:

[code]Title: Something
Author: You
Format: complete

Sub-section Title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

image_name.jpg

Another Sub-section Title

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/code]

In a folder structure like this (assuming you compile as “article.txt”):

article.txt/ article.txt image_name.jpg

The [b]article.txt[/b] file is your MMD file, you can paste this directly into MarsEdit (using HTML mode) and in the preview window, enable Markdown as the text filter. Simply delete the heading material (title/author/etc) at the top; that is MultiMarkdown only, but the rest will be MD compliant so long as you don’t use footnotes and tables.

Now you have a document that is being formatted correctly and has a clear, easy to find (just search for “![“) tag in the text that you can use to update to the correct URL when you upload the image file with MarsEdit. Since you can put raw HTML into an MD file, you can just paste the thumbnail & hyperlink HTML that it gives you right into that spot, replacing the original tag. Accordingly, the above snippet would look like this after being fully revised:

[code]## Sub-section Title ##

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Click to expand.

Another Sub-section Title

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/code]

Or something like that. I’m not exactly sure what your thumbnail code looks like, so just squint if that doesn’t look right. :slight_smile:

Finally, the last step you’ll need to do before publishing this way is to install a Markdown plug-in for Wordpress. The best one for this is “Markdown for Wordpress and bbPress”, which you can find by searching for plugins within the WordPress administration interface. Install is just one-click.

This way you keep your posts in MD, so much easier to edit than converting them to HTML, and it will be a much cleaner transfer than pasting from RTFD too—your material will actually use your theme stylesheets instead of just supplying their own appearance form whatever the RTFD file looked like.

on

Note: MMD is supported by MarsEdit for crunchy footnote goodness.

Therefore the new workflow goes like this (for those who may come to read this later) :

  • write merrily in Scrivener
  • prepare diagrams in OmniGraffle and images in Acorn.
  • Use screen capture utility ( mostly SnapzProX ) to take snapshots of the areas that I want, and size them correctly. Then save these images to a directory on my computer to get them into web ready format (PNG/JPG/GIF etc)
  • Drag these snapshots, or other images into scrivener.
  • write more merrily in Scrivener.
  • Finish with a sense of gratitude.
  • Export the Scrivening to a MMD file. ( Note : This will create a directory with text file and images from the scrivening - all nicely self contained. )
  • Open the MMD directory in Finder.
  • Open the MMD file in TextEdit
  • Select all MMD text and Copy/Paste to MarsEdit Post Window in HTML mode.
  • Select first image and drag it into MarsEdit at the point shown by the “image_name.jpg” tag.
  • The MarsEdit image upload utility will appear. Use wisdom to munge image.
  • the MarsEdit image upload utility will then upload it to my wordpress and insert the appropriate HTML into MarsEdit window at the point of the cursor.
  • Repeat until all images are copied across and uploaded.
  • Switch from HTML Mode to Rich Text mode in MarsEdit post windows and the MMD will be parsed into HTML.
  • Switch from Rich Text mode back to HTML mode to see HTML.
  • Update image tags as needed for Fancybox support (although MarsEdit has customisations to help with this at upload time).
  • A final proofread in MarsEdit and press send.
  • suitable Wordpress munging as a final step.

Requirements:
MarsEdit with MMD installed (a manual process).
Scrivener with MMD installed (a manual process).
A screengrabber/snapshot program that can save web ready format.

It sounds difficult, but honestly, that’s quite straightforward for quality blog posts.

I’m off to test that more thoroughly. Quick test confirms the approach.

Bouncy, happy, joy. Questions answered. Thanks so much.