get advanced images from array

Support MB Group get advanced images from arrayResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #24172
    Martin RybosMartin Rybos
    Participant

    Hi. I hope, it's my last support question. Easy for you difficult for me.
    How could i get images from array to lightbox

    I created an image advanced array on wordpress

    array(
        
        'name'             => 'Add Gallery',
        'id'               => 'gallimage',
        'type'             => 'image_advanced',
        'force_delete'     => false,
        'max_file_uploads' => 10,
        'max_status'       => 'false',
        'image_size'       => 'thumbnail',
    ),

    on frontend i need to make foreach

    $disli = $dislider['gallimage'];//array?
    
    foreach ( $disli as $value ) {
      echo '<a href="'.$value['full_url'].'" data-lightbox="bla"></a>';//give me error
    
      
    }

    Thank you. Sorry, I'm not a coder just a lifetime beginner

    #24173
    Long NguyenLong Nguyen
    Moderator

    Hi Martin,

    For specific field types such as media fields file, file_advanced, file_upload, image, image_advanced, image_upload, single_image, you might need to add some extra code to get the field details.

    $group = rwmb_meta( 'group_id' );
    $image_ids = $group['image_key'] ?? : [];
    foreach ( $image_ids as $image_id ) {
        $image = RWMB_Image_Field::file_info( $image_id, ['size' => 'thumbnail'] );
        echo '<img src="' . $image['url'] . '">';
    }
    

    See more in the documentation https://docs.metabox.io/extensions/meta-box-group/#sub-field-values.

    The code to show images in your case would be:

    $disli = $dislider['gallimage'];//array?
    
    foreach ( $disli as $value ) {
        $image = RWMB_Image_Field::file_info( $value, ['size' => 'thumbnail'] );
        echo '<img src="' . $image['url'] . '">';
    }
    #24186
    Martin RybosMartin Rybos
    Participant

    Ok. thanks it is working but. When i select 3 images to gallery.
    Foreach create 8 images and the last 5 images are the same.
    Do you know why ?

    image

    This is a page
    lightbox
    Icon at the bttom right open lightbox.

    #24192
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I'm not sure how the script (lightbox) implements its code. Please try to contact the script support to ask for help in this case.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.