Image Select Field only offers first option

Support General Image Select Field only offers first optionResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24058
    Beda SchmidBeda Schmid
    Participant

    I added a Image Select Field with a couple options like so:

    
    value:https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a5d8ffad-19df-3aa9-9e06-870146871026.jpg
    value: https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a79b4e0b-a842-300a-a503-8288e4e8603c.jpg
    

    I use AIO, and this is the code it generates:

    
    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
    
    <pre><code>$meta_boxes[] = [
        'title'      => esc_html__( 'Usdfagdhntitled Field Group', 'text-domain' ),
        'id'         => 'usdfagdhntitled-field-group',
        'post_types' => ['post'],
        'context'    => 'normal',
        'priority'   => 'high',
        'fields'     => [
            [
                'id'      => $prefix . 'image_select_8n1slce1j5p',
                'type'    => 'image_select',
                'name'    => esc_html__( 'Image Select', 'text-domain' ),
                'options' => [
                    'value' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a79b4e0b-a842-300a-a503-8288e4e8603c.jpg', 'text-domain' ),
                ],
            ],
        ],
    ];
    
    return $meta_boxes;
    

    }

    We can see it adds only one option, and that is also what I see in the Post Edit Screen: just one option.

    I tried to store the code in the functionsphp and add the other options manually like so

    
    'options' => [
                        'value' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a79b4e0b-a842-300a-a503-8288e4e8603c.jpg', 'text-domain' ),
                        'value' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/537f927b-2c14-3162-8a44-c0ac6c39fc8f.jpg', 'text-domain' ),
                    ],
    

    But it still offers only one image.

    I have tested this with Theme 2021 and no other plugins...

    #24059
    Beda SchmidBeda Schmid
    Participant

    The trick is to increase the array key.

    Hence, the correct code is

    'options' => [
    'value' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/a79b4e0b-a842-300a-a503-8288e4e8603c.jpg', 'text-domain' ),
    'value1' => esc_html__( 'https://the-million-posts--site.tukutoi.com/wp-content/uploads/2020/12/537f927b-2c14-3162-8a44-c0ac6c39fc8f.jpg', 'text-domain' ),
    ],
    ],

    AIO does not do this, it seems.
    Perhaps it is a bug?

    #24060
    Beda SchmidBeda Schmid
    Participant

    OK, I think I misunderstood the hint in the field

    It works, if we indeed alter the value keys in the GUI.

    Sorry the trouble, no issue at all here, can be closed...

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