Marc Witteveen
Marc Witteveen

Reputation: 741

Custom widget in Elementor with the same controls

I am creating a custom Elementor widget with two image controls, unfortunately, I can only get one of the two to work in the content tab. I thought if I add two sections it would work but seems not, looked at Elementor documentation at https://developers.elementor.com/docs/editor-controls/control-media/ but cant find anything there.

$this->start_controls_section(
        'section_image_one',
        [
            'label'             => esc_html__( 'Image One' , $this->domain ),
        ]
    );

    $this->add_control(
        'image',
        [
            'label'             => esc_html__( 'Choose Image', $this->domain ),
            'type'              => Controls_Manager::MEDIA,
            'dynamic'       => [
                    'active'    => true,
            ],
            'default' => [
                    'url'       => Utils::get_placeholder_image_src(),
            ],
        ]
    );
    $this->end_controls_section();

    $this->start_controls_section(
        'section_image_two',
        [
            'label'             => esc_html__( 'Image Two' , $this->domain ),
        ]
    );

    $this->add_control(
        'image',
        [
            'label'             => esc_html__( 'Choose Image', $this->domain ),
            'type'              => Controls_Manager::MEDIA,
            'dynamic'       => [
                    'active'    => true,
            ],
            'default' => [
                    'url'       => Utils::get_placeholder_image_src(),
            ],
        ]
    );
    $this->end_controls_section();

Upvotes: 0

Views: 279

Answers (1)

Marc Witteveen
Marc Witteveen

Reputation: 741

It looks like it is a rather simple solution

.....
$this->add_control(
    'image',
.....

As mentioned on https://developers.elementor.com/docs/editor-controls/regular-control/, the "image" mentioned is a control name and needs to be unique.

Upvotes: 0

Related Questions