<?php

if (!defined('ABSPATH')) {
    exit;
}

class RIZWAN_IMAGE_ALT_TEXT_WEBP_OPTIMIZER_Performance {

    public function __construct() {

        add_filter(
            'wp_get_attachment_image_attributes',
            [$this, 'add_lazy_loading'],
            10,
            3
        );
    }

    public function add_lazy_loading(
        $attr,
        $attachment,
        $size
    ) {

        if (
            !isset(
                $attr['loading']
            )
        ) {

            $attr['loading'] =
                'lazy';
        }

        return $attr;
    }
}