Hello! I'm trying to do dynamic pathes for mediasource.
My plugin for event 'OnMediaSourceGetProperties':
$params = $modx->fromJson($scriptProperties['properties']);
if($modx->resource->id){
$params['basePath']['value'] = str_replace('|id|',$modx->resource->id,$params['basePath']['value']);
$params['baseUrl']['value'] = str_replace('|id|',$modx->resource->id,$params['baseUrl']['value']);
if(!file_exists($modx->getOption('base_path').$params['basePath']['value']))mkdir($modx->getOption('base_path').$params['basePath']['value'], 0766);
}
$modx->log(1,print_r($params,true));
$modx->event->output($modx->toJson($params));
return;
It works well, but I find a problem, when I try to load image through image TV. My plugin doesn't replace pathes because filemanager doesn't send resource id. How can I get resource id when filemanager gets mediasource properties?