Here is the code that updates the topic image_upload_id, it’s in CookedPostProcessor::update_post_image
So what you could do is monkey patch that function and then do something like
def update_post_image
super # call original
if @post.custom_fields[:your_field_name_upload_id]
upload_id = @post.custom_fields[:your_field_name_upload_id]
@post.update_column(:image_upload_id, upload_id) # post
if @post.is_first_post? # topic
@post.topic.update_column(:image_upload_id, upload_id)
end
end
end