Disable lazy loading for specific image

/**
 * Image
 */
class Image {
	/**
	 * Construct
	 */
	public function __construct() {
		add_filter( 'the_content', array( $this, 'disable_lazy_loading' ) );
	}

	/**
	 * Disable lazy loading if specific class is present.
	 */
	public function disable_lazy_loading( $content ) {
		if ( empty( $content ) ) {
			return $content;
		}

		$document = new DOMDocument;

		libxml_use_internal_errors( true );

		$document->loadHTML( $content );

		libxml_clear_errors();

		$figures = $document->getElementsByTagName( 'figure' );

		if ( $figures->length === 0 ) {
			return $content;
		}

		foreach ( $figures as $figure ) {
			$figure_classes = $figure->getAttribute( 'class' );
			$figure_classes = explode( ' ', $figure_classes );

			if ( in_array( 'no-lazy-loading', $figure_classes ) ) {
				$image = $figure->getElementsByTagName('img')[0];
	
				$image->removeAttribute( 'loading' );

				$html = $document->saveHTML();

				return $html;
			}
		}

		return $content;
	}
}