I already tried the solution with the original MIGX snippet and it worked. Thanks for that!
basePath: [[migxResourceMediaPath? &pathTpl=
assets/{context_key}/slider/]]
After your hint I have now rewritten the snippet as follows and it works!
Snippet: backendKey
<?php
$parsedUrl = parse_url($_SERVER['HTTP_REFERER']);
parse_str($parsedUrl['query'], $parsedQuery);
if (isset($parsedQuery['amp;id'])) {
$docid = (int)$parsedQuery['amp;id'];
$resource = $modx->getObject('modResource', $docid );
$ctx = $resource->get('context_key');
$modx->log(MODX_LOG_LEVEL_ERROR, "[migxResourceMediaPath]: docid: $ctx");
return $ctx;
}
basePath in Mediasource: assets/[[backendKey]]/slider/