This question has been answered by igor1509. See the first response.
<?php
// add class to work with gallery extra
$gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
if (!($gallery instanceof Gallery)) return '';
// get id of album
$parent = $modx->getOption('parent',$scriptProperties,0);
if (empty($parent)) return 'no id';
// make query
$c = $modx->newQuery('galAlbum');
$c->where(array(
'id' => $parent,
));
$item = $modx->getObject('galAlbum',$c);
// get result
if (!empty($item)) {
$output = $item->get('name');
}
else {
$output = 'empty';
}
return $output;[[!albumname? &parent=`[[+parent]]`]]
<div id="gallery" class="gallery">
[[!GalleryAlbums? [[!If? &subject=`[[!*parent_gallery]]` &operator=`notempty` &then=`&parent=`[[!*parent_gallery]]` &prominentOnly=`0` &showAll=`0` ` &else=`&prominentOnly=`1` `]] &albumCoverSort=`rank` &rowTpl=`AlbumRowTpl` &thumbWidth=`200` &thumbHeight=`200` &toPlaceholder=`GalleryAlbums`]]
[[!Gallery? &thumbTpl=`ItemThumb[[!get_nojs?]]` &containerTpl=`AlbumTpl[[!get_nojs?]]` &checkForRequestTagVar=`1` &thumbWidth=`200` &thumbHeight=`200` &thumbFar=`C` &thumbZoomCrop=`0` &imageWidth=`800` &imageHeight=`800` &dir=`ASC` &useCss=`0` &toPlaceholder=`Gallery`]]
[[!If? &subject=`[[+Gallery]]` &operator=`isempty` &then=`
<h1>[[*longtitle]]</h1>
<p>[[*description]]</p>
[[+GalleryAlbums]]
` &else=`
[[+Gallery]]
`]]
</div><div class="albumPreview">
<h3>[[+parent]] - [[+name]]</h3>
<div class="thumb">
<a href="[[~2]]/nojs/album/[[+name:urlencode]]/"><img src="[[+image]]" alt="[[+name]]"/></a>
</div>
<div class="desc">
[[+description]]
</div>
</div>