Created
October 4, 2018 19:57
-
-
Save LeMiira/cb51291dc546dd70a832d8e988b0dae1 to your computer and use it in GitHub Desktop.
Image ratio on featured image widget elementor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'elementor/element/before_section_end', function( $element, $section_id, $args ) { | |
/** @var \Elementor\Element_Base $element */ | |
if ('theme-post-featured-image' === $element->get_name()) { | |
$element->add_control( | |
'item_ratio', | |
[ | |
'label' => __( 'Image Ratio', 'elementor-pro' ), | |
'type' => \Elementor\Controls_Manager::SLIDER, | |
'default' => [ | |
'size' => 0.66, | |
], | |
'tablet_default' => [ | |
'size' => '', | |
], | |
'mobile_default' => [ | |
'size' => 0.5, | |
], | |
'range' => [ | |
'px' => [ | |
'min' => 0.1, | |
'max' => 2, | |
'step' => 0.01, | |
], | |
], | |
'selectors' => [ | |
'{{WRAPPER}} .elementor-image' => 'padding-bottom: calc( {{SIZE}} * 100% );', | |
'{{WRAPPER}}:after' => 'content: "{{SIZE}}"; position: absolute; color: transparent;', | |
], | |
// 'condition' => [ | |
// $this->get_control_id( 'thumbnail!' ) => 'none', | |
// $this->get_control_id( 'masonry' ) => '', | |
// ], | |
] | |
); | |
} | |
}, 10, 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
widget css: