I have a page with a wysiwyg editor that allows users to select images from the media library and inserts them into their content and save as a sitecore item.

The problem is that these images aren't published as they're not part of the related items.

I was hoping there's a field that just takes the guids of any related items but it looks like it's all done in the link database. I see a GetItemReferences but no CreateItemReferences or similar.

Essentially I have the id's of the images the user wishes to embed but I don't know how to store each one as a related item.