views:

14

answers:

1

I've implemented markitup to handle users entering markdown text. I want to replace the default image insert command with a nice jquery routine that lets the user browse for an image. I'm able to edit the set.js file to call my javascript routine that brings up the file browser:

{name: 'Picture', key: 'P', call: 'insertImage'},

My insertImage function looks like this:

function insertImage()
{
    // launch Image Browser
}

When the user selects an image in the image browser, another javascript function is called:

function addImage(imageurl,alttext)
{
    var imagetext = "!["+alttext+"]("+imageurl+")";
    // how do I insert imageurl into markitup??
}

I need help implementing addImage.

+1  A: 

You just need to do this:

function addImage(imageurl,alttext)
{
    var imagetext = "!["+alttext+"]("+imageurl+")";
    $.markItUp({ replaceWith: imagetext });
}
TAG