Grouping images [feature request]

For example on homepage: i have 3 groups as images.

  1. Slider
  2. Featured boxes
  3. Footer

I can filter with $files->filterBy() function like: slider_, featured_ and footer_. But filenames are static.

###Sample blueprint

files:
	sortable: true
	groups: true
		slider:
			title: Slider Images
			type: image
		featured:
			title: Featured Boxes
			type: image
		footer:
			title: Footer Images
			type: image

Is that a suggestion? If not, what is your question?

Only feature request :wink:

Well, ok, but by what sort of parameter do you want to group them?

You can group files in your templates, using $files->groupBy(), this requires a meta field to group by, though.

I uploaded all images on panel, OK. So how can i group by slider, featured and footer?

On my feature: Each groups can seperate for ex: 3 area on sidebar. Slider Files Upload Section, Featured Files Upload Area and Footer Files Upload.

I see what you mean, but grouping files in the panel would not help you in your templates. Or only if grouping them would add a new field to your meta files, like it is done when you sort images in the panel. As long as such a feature does not exist, you can add a field to your image meta files, e.g. a field group_by and then filter your images by that field.

Sorry @texnixe I dont understand how to use group_by function. Can you give a simple example please?

Thanks

I think in your case it is more useful to use filterBy() instead of groupBy().

You image meta files should have a select or checkbox field, let’s say “group” with options “slider”, “featured” and “footer”. Then you can filter in your template by that field, e.g.

$sliderImages = $page->images()->filterBy('group', 'slider');

So you mean like that?

files: 
	sortable: true
	fields:
		group:
			label: Group
			type: select
			default: slider
			options:
				slider: Slider
				featured: Featured Box
				footer: Footer

Yes, exactly like that : :smiley:

This is good alternative! Thanks