Display image by id using image_advanced?

Support General Display image by id using image_advanced?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4462
    MD3MD3
    Participant

    How to get image by id using image_advanced?

    I have a multiple section for selectbox and image_advanced

    then below is the output of the data:

    Array
    (
        [0] => Array
            (
                [album_color] => orange
                [album_images] => Array
                    (
                        [0] => 468
                        [1] => 469
                    )
    
            )
    
        [1] => Array
            (
                [album_color] => gray
                [album_images] => Array
                    (
                        [0] => 470
                        [1] => 469
                    )
    
            )
    
    )

    How can i display the image without looping? for example i only want to get the first image in the album orange(id is 468)

    #4475
    Anh TranAnh Tran
    Keymaster

    You can use this code:

    $groups = rwmb_meta( 'group_id' );
    $first_group = !empty( $groups ) && is_array( $groups ) ? reset( $groups ) : array();
    $images = !empty( $first_group['album_images'] ) && is_array( $first_group['album_images'] ) ? $first_group['album_images'] : array();
    $first_image = !empty( $images ) && is_array( images ) ? reset( $images ) : 0;
    
    echo wp_get_attachment_image( $first_image, 'thumbnail' );

    PS: Are you using the Group extension? I see you didn't purchase it.

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