Just in case you're interested, i figured out the solution to my question creating this Snippet:
I don't know if is the best solution, but it works good. That way cms users can select an album using galleryalbumlist TV to associate an Gallery Album with a Post and show the image using getResources for example.
/* Get Cover Album Pic by Album Id */
$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 '';
$files_url = $modx->getOption('gallery.files_url',null,$modx->getOption('core_path').'assets/components/gallery/files/');
$gid = (int)$modx->getOption('gid',$scriptProperties,2);
$output ='';
/* setup thumb properties */
$thumbProperties = array(
'w' => (int)$modx->getOption('thumbWidth',$params,150),
'h' => (int)$modx->getOption('thumbHeight',$params,120),
'zc' => (boolean)$modx->getOption('thumbZoomCrop',$params,1),
'far' => (string)$modx->getOption('thumbFar',$params,'C'),
'q' => (int)$modx->getOption('thumbQuality',$params,90),
'f' => 'jpeg',
);
$c = $modx->newQuery('galItem');
$c->innerJoin('galAlbumItem','AlbumItems');
$c->where(array(
'AlbumItems.album' => $gid,
));
$c->sortby('rank','ASC');
$c->limit(1);
$coverItem = $modx->getObject('galItem',$c);
$output .= $coverItem->get('thumbnail',$thumbProperties);
return $output;
Sure it needs some sanity checks yet, in that line for example:
$gid = (int)$modx->getOption('gid',$scriptProperties,2);
You will need to update to an existing gallery to use as default in case no album is selected in the cms.
Assuming you created an 'image' TV with input type galleryalbumlist you can use the snippet in a normal getResources call of posts:
<img src="[[GalleryCoverPic? gid=`[[+tv.image]]`]]" />
Why not just use galleryItem input type?
For editors its easier to just select from the drop down the gallery you want using the galleryalbumlist input type instead of cropping everytime, etc. If you want to change the cover pic, just drag the image to the first position in the Update Album page.
Then you use a fixed parameters in the snippet call for consistency. Hope it helps.
[ed. note: lithiumlab last edited this post 14 years, 10 months ago.]