make sure media has id assigned before adding attachment