Jump to content

Inline Images and Markdown


Ryan Pierce
 Share

Recommended Posts

Is there a way to use the ProcessWire API to insert images into the text of a Markdown field?

Something kind of like this:

<?php $image1 = $page->image->url; ?>

![This is my image](<?=image1?>)

The end goal here is to be able to write posts in a Markdown-like way but have ProcessWire handle all of the image paths and ordering.

Link to comment
Share on other sites

It isn't, not with 'vanilla' PW.

But there are already some modules that can give you this – search http://modules.processwire.com/ and it's pretty simple to roll your own.

In case you want to build micromodule for yourself, to learn a little, do following:

- create textformatter module – you'll add it to the textarea (before md parsing!)

- comeup with some combination of letters not naturaly used in text

- capture the text

- find correct picture for it

- replace the original text with pictures URL

done. When I did this last time (can't share code due to licensing issues, but it was fun to build it nevertheless), it took something like 20-30 lines to do it (excluding PW's module structure), so… pretty simple. :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...