GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/public_html/wp-content/plugins/around-elementor/modules/image/module.php
<?php

namespace AroundElementor\Modules\Image;

use AroundElementor\Base\Module_Base;
use Elementor\Controls_Manager;
use Elementor\Core\Files\Assets\Files_Upload_Handler;
use Elementor\Core\Schemes;
use Elementor\Utils;



if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

class Module extends Module_Base {

    public function __construct() {
        parent::__construct();

        $this->add_actions();
    }

    public function add_actions() {
        add_action( 'elementor/element/image/section_image/before_section_end', [ $this, 'add_css_classes_controls' ], 10 );
        add_filter( 'elementor/image_size/get_attachment_image_html', [ $this, 'image_html' ], 10, 4 ); 
    }


    public function get_name() {
        return 'override-image';
    }

    public function add_css_classes_controls( $element ) {

        // $element->add_control(
        //     'image',
        //     [
        //         'label' => __( 'Choose Image', 'elementor' ),
        //         'type' => Controls_Manager::MEDIA,
        //         'dynamic' => [
        //             'active' => true,
        //         ],
        //         'default' => [
        //             'url' => Utils::get_placeholder_image_src(),
        //         ],
        //     ]
        // );
        
        $element->add_control(
            'image_class',
            [
               'label'        => esc_html__( 'Image Class', 'around-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'title'       => esc_html__( 'Add your custom class for <img> tag  without the dot. e.g: my-class', 'around-elementor' ),
                'default'     => 'img-fluid',
                'label_block' => true,
                'description' => esc_html__( 'Additional CSS class that you want to apply to the img tag', 'around-elementor' ),
            ]
        );

        $enabled = Files_Upload_Handler::is_enabled();

        if ( $enabled ) {
            $element->add_control(
                'inline_svg',
                [
                   'label'         => esc_html__( 'Inline SVG', 'around-elementor' ),
                    'type'         => Controls_Manager::SWITCHER,
                    'title'        => esc_html__( 'If you are uploading SVG file, it might be useful to inline the SVG files. Do not inline, if your SVG file is from unknown sources.', 'around-elementor' ),
                    'label_on'     => esc_html__( 'Yes', 'around-elementor' ),
                    'label_off'    => esc_html__( 'No', 'around-elementor' ),
                    'return_value' => 'yes',
                    'default'      => 'no',
                ]
            );

            $element->add_control(
                'color',
                [
                    'label'        => esc_html__( 'Color', 'around-elementor' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .around-elementor-svg-wrapper' => 'color: {{VALUE}};',
                    ],
                ]
            );
        }
    }

    public function image_html( $html, $settings, $image_size_key, $image_key  ) {
        $enabled = Files_Upload_Handler::is_enabled();

        if ( $enabled && isset( $settings['inline_svg'] ) && 'yes' === $settings['inline_svg'] && isset( $settings['image']['url'] ) ) {

            if ( isset( $settings['image_class'] ) && ! empty( $settings['image_class'] ) ) {
                $html = '<div class="around-elementor-svg-wrapper ' . esc_attr( $settings['image_class'] ) . '">';
            } else {
                $html = '<div class="around-elementor-svg-wrapper">';
            }
            
            $html .= file_get_contents( $settings['image']['url'] );
            $html .= '</div>';

        } else {

            if ( isset( $settings['image_class'] ) && ! empty( $settings['image_class'] ) ) {
            
                if ( strpos( $html, 'class="') !== false ) {
                    $html = str_replace( 'class="', 'class="' . esc_attr( $settings['image_class'] ) . ' ', $html );
                } else {
                    $html = str_replace( '<img', '<img class="' . esc_attr( $settings['image_class'] ) . '"', $html );
                }                
            }
        }

        return $html;
    }
}