Add images automatically from fileset

Permalink
Hi!

Is it possible to include all images from fileset to global area in page? So that when my customer uploads new image and adds it in certain fileset, the image would appear in page without having to make a new imageblock.

Thanks.

Wanhaonki
 
hutman replied on at Permalink Reply
hutman
There is no block in the Marketplace to do this, however you could do it with code in your template like this

$fs = FileSet::getByName("Fileset Name");
$fileList = new FileList();
$fileList->filterBySet($fs);
$fileList->filterByType(FileType::T_IMAGE);
$fileList->sortByFileSetDisplayOrder();
$files = $fileList->get();
if(count($files) > 0){
     foreach($files as $file){
          //do something with the file $f->getURL();
     }
}
mesuva replied on at Permalink Reply
mesuva
Actually there is a package that does this:
https://www.concrete5.org/marketplace/addons/list-files-from-set1...
Made by yours truly.. :-)

The List Files From Set block will fetch files from a file set automatically and display a list of links. What it doesn't do is output image tags, that's sort of left to the developer to achieve with a custom block template.

It's pretty straightforward to output the images though, and quite a few different ways to acehieve it. One quick (but sort of legacy) way is to include towards the top of the template:
$ih = Core::make('helper/image');

and then within the foreach loop:
$large = $ih->getThumbnail($f, 940, 705, false);
echo '<img src="' .  $thumb->src . '" />';

It depends a bit on what you are wanting to do with the images though, whether they are to be in a lightbox gallery, cropped, whether you want to use concrete5's thumbnail features, new libraries, etc.
hutman replied on at Permalink Reply
hutman
My apologies, the marketplace page for this doesn't look like it will output an actual image, just the filename/file information in a bulleted format.
mesuva replied on at Permalink Reply
mesuva
You're absolutely right, it only lists the files, but it's very handy to
use as the basis for such an activity. I often use it to create galleries
and slideshows.
JohntheFish replied on at Permalink Reply
JohntheFish
For the 5.4,5.5,5.6 version of List Files From Set I created Image List Templates. A set of image display templates that does just that. I shouldn't be difficult to port them to 5.7.

https://www.concrete5.org/marketplace/addons/image-list-templates...