<?php
/**
* Class: Jet_Elements_Images_Layout
* Name: Images Layout
* Slug: jet-images-layout
*/
namespace Elementor;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Modules\DynamicTags\Module as TagsModule;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Jet_Elements_Images_Layout extends Jet_Elements_Base {
public function get_name() {
return 'jet-images-layout';
}
public function get_title() {
return esc_html__( 'Images Layout', 'jet-elements' );
}
public function get_icon() {
return 'jet-elements-icon-images-layout';
}
public function get_jet_help_url() {
return 'https://crocoblock.com/knowledge-base/articles/how-to-create-an-attractive-image-grid-masonry-or-justify-layout-with-jetelements-images-layout-widget-for-elementor/';
}
public function get_categories() {
return array( 'cherry' );
}
public function get_script_depends() {
return array( 'imagesloaded', 'jet-salvattore' );
}
/**
* [$item_counter description]
* @var integer
*/
public $item_counter = 0;
protected function _register_controls() {
$css_scheme = apply_filters(
'jet-elements/images-layout/css-scheme',
array(
'instance' => '.jet-images-layout',
'list_container' => '.jet-images-layout__list',
'item' => '.jet-images-layout__item',
'inner' => '.jet-images-layout__inner',
'image_wrap' => '.jet-images-layout__image',
'image_instance' => '.jet-images-layout__image-instance',
'content_wrap' => '.jet-images-layout__content',
'icon' => '.jet-images-layout__icon',
'title' => '.jet-images-layout__title',
'desc' => '.jet-images-layout__desc',
'button' => '.jet-images-layout__button',
)
);
$this->start_controls_section(
'section_items_data',
array(
'label' => esc_html__( 'Items', 'jet-elements' ),
)
);
$repeater = new Repeater();
$repeater->add_control(
'item_image',
array(
'label' => esc_html__( 'Image', 'jet-elements' ),
'type' => Controls_Manager::MEDIA,
'default' => array(
'url' => Utils::get_placeholder_image_src(),
),
'dynamic' => array( 'active' => true ),
)
);
$repeater->add_control(
'item_image_size',
array(
'type' => 'select',
'label' => esc_html__( 'Image Size', 'jet-elements' ),
'default' => 'full',
'options' => jet_elements_tools()->get_image_sizes(),
)
);
$this->_add_advanced_icon_control(
'item_icon',
array(
'label' => esc_html__( 'Icon', 'jet-elements' ),
'type' => Controls_Manager::ICON,
'label_block' => true,
'file' => '',
),
$repeater
);
$repeater->add_control(
'item_title',
array(
'label' => esc_html__( 'Title', 'jet-elements' ),
'type' => Controls_Manager::TEXT,
'dynamic' => array( 'active' => true ),
)
);
$repeater->add_control(
'item_desc',
array(
'label' => esc_html__( 'Description', 'jet-elements' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => array( 'active' => true ),
)
);
$repeater->add_control(
'item_link_type',
array(
'label' => esc_html__( 'Link type', 'jet-elements' ),
'type' => Controls_Manager::SELECT,
'default' => 'lightbox',
'options' => array(
'lightbox' => esc_html__( 'Lightbox', 'jet-elements' ),
'external' => esc_html__( 'External', 'jet-elements' ),
'no_link' => esc_html__( 'No link', 'jet-elements' ),
),
)
);
$repeater->add_control(
'item_url',
array(
'label' => esc_html__( 'External Link', 'jet-elements' ),
'type' => Controls_Manager::TEXT,
'default' => '#',
'condition' => array(
'item_link_type' => 'external',
),
'dynamic' => array(
'active' => true,
'categories' => array(
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
),
),
)
);
$repeater->add_control(
'item_target',
array(
'label' => esc_html__( 'Open external link in new window', 'jet-elements' ),
'type' => Controls_Manager::SWITCHER,
'return_value' => '_blank',
'default' => '',
'condition' => array(
'item_link_type' => 'external',
),
)
);
$repeater->add_control(
'item_rel',
array(
'label' => esc_html__( 'Add nofollow', 'jet-elements' ),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'nofollow',
'default' => '',
'condition' => array(
'item_link_type' => 'external',
),
)
);
$this->add_control(
'image_list',
array(
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => array(
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #1', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #2', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #3', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #4', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #5', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
array(
'item_image' => array(
'url' => Utils::get_placeholder_image_src(),
),
'item_title' => esc_html__( 'Image #6', 'jet-elements' ),
'item_desc' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'jet-elements' ),
'item_url' => '#',
'item_target' => '',
),
),
'title_field' => '{{{ item_title }}}',
)
);
$this->end_controls_section();
$this->start_controls_section(
'section_settings',
array(
'label' => esc_html__( 'Settings', 'jet-elements' ),
)
);
$this->add_control(
'layout_type',
array(
'label' => esc_html__( 'Layout type', 'jet-elements' ),
'type' => Controls_Manager::SELECT,
'default' => 'masonry',
'options' => array(
'masonry' => esc_html__( 'Masonry', 'jet-elements' ),
'grid' => esc_html__( 'Grid', 'jet-elements' ),
'justify' => esc_html__( 'Justify', 'jet-elements' ),
'list' => esc_html__( 'List', 'jet-elements' ),
),
)
);
$this->add_responsive_control(
'columns',
array(
'label' => esc_html__( 'Columns', 'jet-elements' ),
'type' => Controls_Manager::SELECT,
'default' => 3,
'options' => jet_elements_tools()->get_select_range( 6 ),
'condition' => array(
'layout_type' => array( 'masonry', 'grid' ),
),
)
);
$this->add_control(
'shuffle_image_list',
array(
'label' => esc_html__( 'Shuffle Image List', 'jet-elements' ),
'type' => Controls_Manager::SWITCHER,
'default' => '',
)
);
$this->add_responsive_control(
'item_height',
array(
'label' => esc_html__( 'Item Height', 'jet-elements' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array( 'px', 'vh' ),
'range' => array(
'px' => array(
'min' => 100,
'max' => 1000,
),
),
'default' => array(
'size' => 300,
'unit' => 'px',
),
'condition' => array(
'layout_type' => 'grid',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image_instance'] => 'height: {{SIZE}}{{UNIT}};',
),
)
);
$this->add_control(
'justify_height',
array(
'label' => esc_html__( 'Justify Height', 'jet-elements' ),
'type' => Controls_Manager::NUMBER,
'default' => 300,
'min' => 100,
'max' => 1000,
'step' => 1,
'condition' => array(
'layout_type' => array( 'justify' ),
),
)
);
$this->add_responsive_control(
'item_margin',
Loading ...