芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/rentandbuyrealty.com/web/src/Components/Cards/ImageToSvg.jsx
import { settingsData } from '@/store/reducer/settingsSlice'; import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; // Function to convert an image URL to inline SVG export const ImageToSvg = ({ imageUrl, className }) => { const [svgContent, setSvgContent] = useState(''); useEffect(() => { const convertImageToSvg = async () => { try { const response = await fetch(imageUrl); const originalSvgContent = await response.text(); // Replace
with
const modifiedSvgContent = originalSvgContent.replace(/
([\s\S]*?)<\/defs>/, ''); setSvgContent(modifiedSvgContent); } catch (error) { console.error('Error converting image to SVG:', error); } }; convertImageToSvg(); }, [imageUrl]); return
; };