Dear MODX people,
if you have a gallery and would like the first image of an album to use another template than all others, you can do it like this:
In your gallery call, you have the thumbnail template chunk mentioned like this:
So just add this line to pass a new variable to the gallery script which contains the new template for the first image:
&firstThumbTpl=`galItemThumbFirst`
Now, in your snippets, go to gallery folder and open "Gallery". Scroll down to the place near
Now, edit the lines before that like this:
$output[] = $gallery->getChunk($modx->getOption('thumbTpl',$scriptProperties,'galItemThumb'),$itemArray);
$idx++;
The lines above become these:
if ($idx=="0") {
$output[] = $gallery->getChunk($modx->getOption('firstThumbTpl',$scriptProperties,'galItemThumbFirst'),$itemArray);
}
else {
$output[] = $gallery->getChunk($modx->getOption('thumbTpl',$scriptProperties,'galItemThumb'),$itemArray);
}
$idx++;
That's it. When the Gallery Script displays the first image of an album, it will read and output another template chunk for it and still work the same. To have different image sizes (first image is big) this could look like this:
galItemThumb
<div class="[[+cls]] box frame">
<a href="[[+image_absolute]]" title="[[+name]]" class="cb" [[+link_attributes]]>
<img class="[[+imgCls]]" src="[[+image_absolute:pthumb=`w=288&h=288&zc=1`]]" alt="[[+name]]" [[+image_attributes]] />
</a>
</div>
and the modified (other image size)
[b]galItemThumbFirst[/b]
<div class="[[+cls]] box frame">
<a href="[[+image_absolute]]" title="[[+name]]" class="cb" [[+link_attributes]]>
<img class="[[+imgCls]]" src="[[+image_absolute:pthumb=`w=928&h=928&zc=1`]]" alt="[[+name]]" [[+image_attributes]] />
</a>
</div>
Hope you can use it if you found it here.
Cheers,
Guido