I write UML diagrams in org-mode with PlantUML and usually "compile" it to HTML to view the result. Is there a way to have the image show up in my buffer?

I try to enable iimage-mode but it doesn't work well. It replaces the file name at the start of the source block.

#+begin_src plantuml :file my-diagram.png

Both references to the filename get replaced and the source stays. Is there a way to hide the source block and only show one instance of the image?

2 Answers 2


I'm not so sure about replacing the source with an image, but you can have inline images as results to source blocks.

If you add the startup option "inlineimages" to your buffer, any links in your buffer that point to local images it understands will be rendered.

If you don't have a startup options block, it would just be a line at the top of your file that looks like: #+STARTUP: inlineimages.

This only fixes half of your problem though...when you C-c C-c a block that spits out an image, you will get a link rather than an inline image...

Luckily, you can fix this by adding the following to your Emacs config:

(add-hook 'org-babel-after-execute-hook
          (lambda ()
            (when org-inline-image-overlays

This will allow you to see images inline when you first open the buffer, and update them by evaluating the block source.

Now, as for the whole source-replacing business:

I'm not sure how to do this inside of your Org buffer, but in Org exports (To HTML, PDF, and so on...), if you don't want to show the source blocks that generate their results, you can add an ":exports results" argument to the head of your code block. This will make it appear as though the source has been replaced with your image result.

  • Current versions of emacs will export plantuml as images without sources by default. If you don't want to see the source in the org buffer, simply collapse the code block (tab-key at begin_src) line. I'm sure there's an easy way to auto-collapse the block as an extension of the after-execute hook if someone really wanted.
    – Digicrat
    Feb 28, 2020 at 3:57

From org-mode 8.2.10 onwards it has been possible to add the :eval no-export argument to the code block header. The result is that code block is executed normally but not exported. Only the output, figure in this case, after the #+RESULTS: line is visible in the exported document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.