add_control( 'cei_image_custom_class', [ 'label' => __( 'Custom Class', 'add-class-to-elementor-image' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => __( 'your-custom-class-here', 'add-class-to-elementor-image' ), ] ); } /** * Add custom class * * Add custom class to HTML img. * * @since 1.0 * * @access public */ public function add_custom_class( $html, $settings, $image_size_key, $image_key ) { if( isset( $settings['cei_image_custom_class'] ) && ! empty( $settings['cei_image_custom_class'] ) ) { return preg_replace( '/class="(.*)"/', 'class="' . $settings['cei_image_custom_class'] . ' \1"', $html ); } else { return $html; } } } ACEI_Init::instance();