# Post cook for images?

**URL:** https://meta.discourse.org/t/post-cook-for-images/57148
**Category:** Development
**Created:** [2017年二月9日 01:58 UTC](https://meta.discourse.org/t/post-cook-for-images/57148 "2017-02-09T01:58:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [2017年二月9日 01:58 UTC](https://meta.discourse.org/t/post-cook-for-images/57148/1 "2017-02-09T01:58:03Z")

</div>

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"
post.save

```

..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 = "https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/3X/9/d/9d543e92b15b06924249654667a81441a55867eb_1_690x184.png\n\n"
post.save

```

..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.

---

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [2017年二月9日 03:09 UTC](https://meta.discourse.org/t/post-cook-for-images/57148/2 "2017-02-09T03:09:58Z")

</div>

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

```
post.raw = "<img src='https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/3X/9/d/9d543e92b15b06924249654667a81441a55867eb_1_690x184.png'/>\n\n"

```

post.save

..means that it cooks on the save fine now.
