Editorial Workflows

Share with Images

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Converts local image files that are referenced in the current (Markdown) document to equivalent base64-encoded data URIs. Afterwards, the document is converted to HTML and passed to a share sheet.

This is a small modification to Ole Moritz’s “Send with Images” workflow. It can be used for alternative email apps or other apps that accept HTML.

NOTE: Some older browsers limit the size of base64 encoded images, and it’s not very efficient. Best for small images like icons or logos.

Shared by: Larry Stevens

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import mimetypes
import re
import editor
import base64
import os

def main():
	p = editor.get_path()
	os.chdir(os.path.split(p)[0])
	text = editor.get_text()
	def repl(m):
		alt = m.group(1)
		filename = m.group(2)
		try:
			with open(filename, 'r') as f:
				img_data = f.read()
				img_type = mimetypes.guess_type(filename)[0]
				data_url = 'data:%s;base64,%s' % (img_type, base64.b64encode(img_data))
				return '![%s](%s)' % (alt, data_url)
		except:
			return m.group(0)
		return m.group(1)
	
	text2 = re.sub(r'!\[(.*?)]\((.*?)\)', repl, text)
	workflow.set_output(text2)

main()
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Share Text or URL ?
Text
<html> <head><meta charset=”utf-8”/></head> <body>Input</body> </html>
Share as
  • Text
  • URL