What's the best solution for having a 'gallery' block inside of a Matrix? By 'gallery block' I mean an ability to have multiple images, with captions, alt, and link, presented as a gallery on the front-end, but as part of a parent Matrix (the user needs to control the location of the gallery within the page content, so the page content is a Matrix).

What I really need is a Matrix within a Matrix, but that's not possible with Craft at the moment. I'd thought using a Table type inside the Matrix might work, but Craft doesn't offer Asset as a type for use inside a Table (makes sense, this would be a hacky use of 'table').

Another work-around might be to just have 'singular image' blocks and have the Template code notice when multiple Image blocks occur as siblings, and convert those into gallery mark-up - but I've no idea how to code that, if it's even possible.

Do you have better solutions?


2 Answers 2


Another option is to create a galleryImage channel (with Entries in this section have their own URLs not checked), and then make your matrix block be a collection of entries in galleryImage added via an Entries field. Each galleryImage would have the image, caption, etc.

  • That sounds a pretty flexible solution I'd not thought of, thanks! Aug 11, 2014 at 8:33

I guess it depends on what information each Asset needs to contain. As you mentioned, a Matrix within a Matrix is not possible, so you will need a different method to attach additional information to each Asset.

One method that may work is to create Asset Meta Fields for Assets. This way, you can define additional things on each image on the Asset level. For example, you could have custom fields for things like title, description, copyright, etc.

With Asset Meta Fields in place, you could define one "Gallery" Matrix block that allows for multiple files to be selected. The order could be controlled by drag/dropping each of the selected Assets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.