<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
use Elementor\Controls_Manager;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
* Class Project
*/
class Motiox_Elementor_Project_Thumbnail extends Elementor\Widget_Base {
public function get_name() {
return 'motiox-project-thumbnail';
}
public function get_title() {
return esc_html__('Motiox Thumbnail', 'motiox');
}
public function get_categories() {
return array('motiox-addons');
}
protected function register_controls() {
$this->start_controls_section(
'section_layout',
[
'label' => esc_html__('Layout', 'motiox'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_responsive_control(
'width',
[
'label' => esc_html__( 'Width', 'motiox' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => '%',
],
'tablet_default' => [
'unit' => '%',
],
'mobile_default' => [
'unit' => '%',
],
'size_units' => [ '%', 'px', 'vw' ],
'range' => [
'%' => [
'min' => 1,
'max' => 100,
],
'px' => [
'min' => 1,
'max' => 1000,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} img' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'height',
[
'label' => esc_html__( 'Height', 'motiox' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => 'px',
],
'tablet_default' => [
'unit' => 'px',
],
'mobile_default' => [
'unit' => 'px',
],
'size_units' => [ 'px', 'vh' ],
'range' => [
'px' => [
'min' => 1,
'max' => 900,
],
'vh' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} img' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'object-fit',
[
'label' => esc_html__( 'Object Fit', 'motiox' ),
'type' => Controls_Manager::SELECT,
'condition' => [
'height[size]!' => '',
],
'options' => [
'' => esc_html__( 'Default', 'motiox' ),
'fill' => esc_html__( 'Fill', 'motiox' ),
'cover' => esc_html__( 'Cover', 'motiox' ),
'contain' => esc_html__( 'Contain', 'motiox' ),
],
'default' => '',
'selectors' => [
'{{WRAPPER}} img' => 'object-fit: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
public function render() {
$settings = $this->get_settings_for_display();
if(is_singular('motiox_project') || is_singular('motiox_services')) {
the_post_thumbnail('full');
}
}
}
$widgets_manager->register(new Motiox_Elementor_Project_Thumbnail());