The last link leads to a way of working where this would be easier to do, using Pandoc Markdown as a writing method in the editor, and using that system to generate the ePub file.
It’s also worth noting that Scrivener can insert raw HTML into the rich text based ePub and KF8 file types. You will very likely still need to handle the media on your own and construct the final .epub, either as a source folder or in an editing tool, but you could at least get the pointers to the media inserted into the output. I posted an extensive guide on how to do something similar to this in this thread, where the intent was to create one’s own figure output so that alt text could be included in the img element.
Moderator note: moved to the technical support board. The “Using Scrivener”" board is meant for posting tips and usage scenarios.
.:. Ioa Petra'ka “Whole sight, or all the rest is desolation.” —John Fowles