How to make list of items, with an image and text for each item


#1

I need to make a field which allows users to upload an image with some text through the panel – e.g. Client name + related image, and then upload as many of these blocks on a given page as they want.

What would be the best way to do this?


#2

You can use a structure field: https://getkirby.com/docs/cheatsheet/panel-fields/structure


#3

Thank you – but how would I make all the information (URL, dimensions, orientation) for each Image field accessible within the JSON request?

i.e. using https://github.com/lord-executor/kirby-json-api , my ideal result would be:

"structured": [
	{
		"title": "My Title",
		"file": {
                            url: "....",
                            title: "....",
                            dimensions: "....",
                            orientation: "....",
                    }
	},
	{
		"title": "Sub-Item 2",
		"file": {
                            url: "....",
                            title: "....",
                            dimensions: "....",
                            orientation: "....",
                    }
	},
	{
		"title": "Last",
		"file": {
                            url: "....",
                            title: "....",
                            dimensions: "....",
                            orientation: "....",
                    }
	}
]

and not:

"structured": [
	{
		"title": "My Title",
		"message": "filename.jpg"
	},
	{
		"title": "Sub-Item 2",
		"image": "filename.jpg"
	},
	{
		"title": "Last",
		"image": "filename.jpg"
	}
]

#4

I’m not that familiar with the plugin, but you can access the file from what is stored in the field (using the toFile() method) and then get the information from the file object, probably using the plugins mapField() function.

If necessary, contact the plugin developer for more information.


#5

You can also use the Kirby Api: https://getkirby.com/docs/cookbook/json