Image Gallery Control
The image gallery control lets you select multiple images from your media library. Once images have been selected you can choose the image size.
Your selected images are stored in an array, which you have to loop through (see code example below). Use the id and size of each image to render it on your page.
class Prefix_Element_Image extends \Bricks\Element { // Set builder controls public function set_controls() { $this->controls['exampleImageGallery'] = [ 'tab' => 'content', 'label' => esc_html__( 'Image gallery', 'bricks' ), 'type' => 'image-gallery', ]; }
// Render element HTML public function render() { if ( isset( $this->settings['exampleImageGallery'] ) ) { foreach( $this->settings['exampleImageGallery'] as $index => $image ) { echo wp_get_attachment_image( $image['id'], $image['size'], false, ['class' => 'css-filter'] ); } } else { esc_html_e( 'No image(s) selected.', 'bricks' ); } }} Was this page helpful?