Should You Use .svg Images in WordPress Posts?

Graphics make blog posts and web pages better. A picture is worth a thousand words—but including pictures on the web is harder than it should be. There is a whole alphabet soup of formats, graphic features such as transparency, different resolutions and the dreaded browser compatibility. Wouldn’t it be nice if creating and publishing graphics was as straight-forward as publishing text?

New and Improved: .svg or Scalable Vector Graphics

.svg images WordPress

.svg images in WordPress are here! This is the official .svg logo (in .svg format) served up from this blog’s media library using the Safe SVG plugin.

I’ve been tracking .svg for some time. .svg format stands for “scalable vector graphic,” which is described in a W3C specification. The format provides a modularized language for describing two-dimensional vector and mixed vector/raster images.

As of February 2017, .svg delivers numerous advantages for designers and developers alike. .svg images are supported by most browsers. The files are tiny compared to it’s .png and .jpeg brethren. And there are multiple tools, including my favorite graphic design tool, Sketch 3, that save files to the .svg format.

The advantages of .svg come from an industry standard format that comprises (1) vector graphic shapes (e.g., paths consisting of straight lines and curves), (2) raster images and (3) text that display beautifully in all modern browsers. In other words, the .svg image file contains instructions for rendering images at any resolution rather than compressed rasters. And for the designer and webmaster, this means you have a single tiny file to manage rather than exporting 1x, 2x and 4x versions from a graphic tool which need to be managed in a CDN or media library and delivered to desktop, mobile and retina displays based on the viewport setting…very, very complex.

With the advantages of broad compatibility, tiny files and simplicity, it’s time to make a switch. Or is it?

.svg Images in WordPress…Not For the Masses…Not Yet

As of February 2017, WordPress doesn’t officially support .SVG images. Sure it’s easy to enable SVG in your WordPress instance through a function or a plugin. But if it’s easy to support the .svg image format, why isn’t support included in WordPress core?  The answer: security.

It turns out that the .svg format is more of a document format than an image format. That means you can embed all sorts of things in a .svg file. This includes JavaScript. So that seemingly benign graphic could easily contain a not-so-benign script that hijacks visitors, data and web experiences. Not so good. And with 25% of the web running on WordPress, the core development team prioritizes security and reliability over simplicity. The four years of engineering debate is visible to all in WordPress Trac ticket 24251.

.svg Images in Controlled WordPress Sites: Bring On .svg!

In sites where only skilled web designers and publishers with a strict file chain of custody procedure, the advantages of .svg can be realized today. For security, I strongly recommend that you think twice about deploying .svg support by hacking the functions.php file and or using the less secure plugins that you can easily find in the WordPress Plugin Directory.

Instead, focus first on training and procedures to mitigate potential risks from .svg. Just as you wouldn’t let anybody upload JavaScript to your site, you shouldn’t let just anyone upload .svg files to your site. The first and safest approach is to let savvy designers include .svg files in theme assets:

  1. Produce your own .svg files or review code in files provided by others
  2. Run the .svg file through a sanitizer, like DOMpurify
  3. Save the resulting code locally.
  4. Add the .svg file to your CDN or production file system
  5. Directly reference the sanitized file with CSS or HTML code <img src="/blah/file.svg" />

How About Media Libraries?

Enabling the media library opens more risk. If you are ready to limit access to the media libary using WordPress user roles, the risks should be manageable. There is one .svg plugin I can recommend today: Safe SVG by Daryll Doyle. It not only enables the .svg mime type for the media library, but it sanitizes .svg files on upload. The plugin is young but works. And developer Daryll Doyle is actively developing Safe SVG. He deserves our support!

.svg has a bright future for web publishers who value great user experiences with content and compatible graphics files that are simple to manage. Let’s embrace a secure future for SVG and WordPress.

How to Transcribe .MP3 Audio from Podcasts or .MP4 Movies to Text on Mac OS

 June 2017: a key component for these instructions is no longer actively maintained, so these instructions are no longer valid for Modern Mac configurations.

I listen to podcasts. I watch videos. I watch podcasts of different languages. But more than anything I read and write. I practice languages. That’s just how I roll. And sometimes, my ramblings bring me as far as understanding English meaning of some specific kikuyu translation texts.

Frequently I want to save an audio snippet or video clip for future reference. Sure I could save the source media file, if I had unlimited disk space. But what I usually do is keep a link to the original source and text synopsis of the snippet. That both saves on storage and makes future searches for that particular item simpler.

If you’re like me, you really want the original text more than a synopsis. It take s a bit of extra effort, but I have a nice solution that uses only a Mac and open source software. Read below for instructions on converting an MP3 audio file to a text document.

The Basics of Configuring Your Mac to Transcribe .MP3 Audio

Here’s what you need:

  • The original media (.mp3 file, for example)
  • Soundflower. Soundflower is an application that creates a virtual audio channel and directs audio input and output to physical or virtual devices.
  • Audacity. Audacity is a free application for recording and editing sounds.
  • TextEdit.app. TextEdit is the default text editor/word processor that is included in Mac OS X.

Follow the instructions on the developer websites to get all of the software installed and working on your system. Once you have the software installed, the next step is to configure your Mac to use Soundflower for dictation.

Transcribe mp3 audio: Dictation and Speech
  • Open System Preferences and click on  “Dictation & Speech”
  • Select the Dictation tab
  • Select “Soundflower (2ch)” as the dictation input source
  • Click Dictation to “On”
  • Tick the “Use Enhanced Dictation” box

Your Mac is ready for dictation. When dictation is turned on in TextEdit (or a another word processing app), your Mac will transcribe sound from the Soundflower input source.

Getting Your Audio and Text Files Ready

Next, you need to queue up the audio file in Audacity and direct output to Soundflower. For those who are new to Audacity, this will be the trickiest step. But relax, you don’t need to learn much about Audacity beyond deciding what section of sound to play and how to select the audio output from the default speakers to Soundflower.

Transcribe .MP3 Audio to Text - Audacity
  • Launch Audacity
  • Import your audio file into audacity (File–> Import, or simply drag the file into the center of the Audacity screen.)
  • Click the play button to give it a listen, then click stop once your confident you have the right sound clip/transcription area.
  • Choose Audacity –> Preferences –> Devices. Under playback, choose “Soundflower (2ch)” to switch the output from the onboard speakers to Soundflower. Click “OK”
Transcribe .mp3 audio: Audacity Preferences Dictation

With Audacity and your sound file queued up, its time to turn your attention to TextEdit.

  • Launch TextEdit
  • Create a “New Document”
  • You may want to add some meta data to the document, such as the podcast name, episode #, publish date and URL, to go along with the key transcript.
  • Position the cursor in the file where you want the transcript to appear.

And … Action!

It’s time to start audio playback and dictation transcription. Here both sequence and timing are important:

Transcribe .MP3 audio: Start Dictation
  1. In Audacity, move the scrubber start location 10-15 seconds before the key transcription area.
  2. Press “Play.” The scrubber and meters will start moving, though you won’t hear any sound. The audio signal is going to Soundflower instead of to the speakers.
  3. Put focus on Text edit and position the cursor where you want the transcription to begin.
  4. Select Edit –> Start Dictation. (or use the hot key combination, Fn Fn). A microphone icon with a “Done” button will appear to the left of your document.
  5. Text will start appearing in the document. It will likely lag by about 3-5 seconds.
  6. After approximately 30 seconds press the “done” button. Transcription will continue until complete.

This is the fun part: watch as transcription happens in real time right in the document window. Look Ma, no hands!

And now you have the original text (and most likely a few errors) as text to save. In the future you can easily search and retrieve the information.

An Excellent Alternative: Google Docs Voice Typing

While the solution above works great for offline work, one alternative with a lot of promise is Google Docs. The Voice Typing feature work much like the dictation service in Mac OS. It has the crowdsourcing advantages and privacy disadvantages of other Google products. If you’re OK with that, I found Voice Typing to do an very good job with accuracy and it can go longer that Mac OS dictation.

To use Google Voice Typing, follow all of the steps above with Soundflower, Dictation preferences and configuring Audacity.  Instead of using TextEdit, you’ll want to start the Chrome browser and create a Google Doc. Once you are in document, Select Tools –> Voice typing

Transcribe .mp3 Audio with Google Voice Typing

The user interface and process of starting and stopping transcription is the same as with TextEdit.

Dictation and Transcription Limitations

This process sets you well on you way to the goal of a high fidelity audio transcription. But it will be short of perfect. Here’s what you can do to go from good to perfect:

  • Understand that Mac OS dictation transcription works for a maximum of 30 seconds at a time. If you need longer, you may want to use an alternate technology such as Dragon.
  • Audio playback needs to start before dictation/transcription begins in TextEdit. TextEdit needs to be in focus for dictation to work. If you set the Audacity scrubber a few seconds ahead of target snippet, you’ll be fine.
  • Transcription cannot intuit punctuation. You’ll need to add that after the fact.
  • If you have multiple speakers or a noisy background, you may need to complete one additional step of creating a pristine audio file to work from. This can be done by listening to the sound through headphones and speaking the text into an audio recorder. Use the recording of your voice to drive the transcription.