getAttribute( 'src' ) ); if ( ! file_exists( $file ) ) { return $html; } $svg = $dom->importNode( dom( file_get_contents( $file ) )->documentElement, true ); if ( ! method_exists( $svg, 'setAttribute' ) ) { return $html; } $svg->setAttribute( 'width', $img->getAttribute( 'width' ) ); $svg->setAttribute( 'height', $img->getAttribute( 'height' ) ); $svg->setAttribute( 'aria-label', $img->getAttribute( 'alt' ) ); $svg->setAttribute( 'class', $img->getAttribute( 'class' ) ); ( $link ?? $div )->removeChild( $img ); ( $link ?? $div )->appendChild( $svg ); $html = $dom->saveHTML(); } return $html; }