get_media_path: add fallback to allow using Galleries with standalone placeholder

Hi, I am using cmsplugin_gallery with placeholderfields in my models, so I added this code from CMSPluginbase to cope with pages not existing. 
Also, I do not wish to use the default template, so instead of having its name hardcoded, I modified the model to default to the first template available.
Cheers.