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. Cheers.