Community

Get basepath from Media source by id?

IS there a way to get the basepath form a media source in a snippet?
I’m using Image+ and need to get the image URL including the path of the media source it uses.
I only know the media source ID so what is the quickest way to get the PATH form a media source?
TNX
RDG

the snippet addmediasourcepath from here could do that
https://docs.modx.com/extras/revo/migxdb/migxdb.tutorials/migxdb.create-a-basic-gallery-management-from-scratch-with-migxdb/add-resource-specific-mediasource-and-multifile-uploader-to-the-gallery

This might work (assuming that it’s a file media source object):

$ms = $modx->getObject('modFileMediaSource', $mediaSourceId);
$bases = $ms->getBases();

$absolutePath = $bases['pathAbsolute'];
$relativePath  = $bases['pathRelative'];

It might be more correct to call getObject() with the parent class if it works:

$ms = $modx->getObject('modMediaSource', $mediaSourceId);

Tnx Bobray,

that works