Skip to content

Instantly share code, notes, and snippets.

@litonarefin
Created December 31, 2019 09:44
Show Gist options
  • Save litonarefin/f8c0dc9f480d2cab2a76279103a268b7 to your computer and use it in GitHub Desktop.
Save litonarefin/f8c0dc9f480d2cab2a76279103a268b7 to your computer and use it in GitHub Desktop.
Add External Image option for Backgrounds
extend the Group Control Base in my plugin to create an external background image option field to go with the standard classic background options.
class Group_Control_Background_trchristensen extends Group_Control_Background {
public function init_fields() {
$fields = parent::init_fields();
//here you add your field
$fields['ext_image'] = [
'label' => _x( 'External Image', 'Background Control', 'elementor' ),
'type' => Controls_Manager::TEXT,
'title' => _x( 'Background Image', 'Background Control', 'elementor' ),
'selectors' => [
'{{SELECTOR}}' => 'background-image: url("{{URL}}");',
],
'condition' => [
'background' => [ 'classic' ],
],
];
return $fields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment