0

I have the code as follows for creating a custom module in Beaver Builder:

'my_multiple_photos_field' => array(
'type'          => 'multiple-photos',
'label'         => __( 'Multiple Photos Field', 'fl-builder' )

),

Now i want to display all the images in this array. This is not working.

<div class="fl-example-image">
<?php echo "<img src='".$settings->my_multiple_photos_field_src."'>" 
?>

  • you need to loop over this array and preview each one as a separate element – hassan May 15 '17 at 10:46
  • you need to loop like this foreach($settings->my_multiple_photos_field_src as $src) { echo ""; } – JYoThI May 15 '17 at 10:49
  • That is not working Jyothi. I am able to echo single images when I create a different module. You can check the documentation here https://www.wpbeaverbuilder.com/custom-module-documentation/ – RAMSHID KN May 15 '17 at 13:06

1 Answers1

0

this setting field from Beaver Builder:

'my_multiple_photos_field' => array(
    'type'          => 'multiple-photos',
    'label'         => __( 'Multiple Photos Field', 'fl-builder' )
),

will give you an array of ids --> attachment-ids.

so if you need those images, you have to get the url for the src-tag.

with: wp_get_attachment_url( int $attachment_id )

$output = '';
$output = '<div class="fl-example-image">';
foreach($settings->my_multiple_photos_field_src as $imageid){
    $src = wp_get_attachment_url( (int) $imageid );
    $output .= "<img src='" . $src . "' />";
}  
$output .= '</div>'; // close imageholder 

echo $output;

The code goes into your frontend.php, as described in the docs from beaver builder: Custom module developer guide

TheShah
  • 61
  • 5