Post cook for images?

I have a very simple plugin (server-side) I was playing around with.

For this part of the call:

on(:post_created) do |post, params|

I use the post.raw to put some content in:

post.raw = "@#{post.user.username} says hello!\n\n"

…and it works great. Cool.

My question is how to embed an image, as in the same result as when the post cooks in the preview editor?

If I change it to something like this:

post.raw = "\n\n"

…then the post shows the plain image address text and not the preview image. If I open edit on the post manually in the UI it works ok (shows the image preview), just not on my post save.

Looking through the code, am I meant to call ‘post.cook’ after the save to trigger this?

Thanks for any help or pointers to examples.

I solved this by putting the image into an IMG tag within the raw format, i.e.

post.raw = "<img src=''/>\n\n"

…means that it cooks on the save fine now.