For the #patternImage
image tag, I have successfully loaded a base64encoded image into the 'xlink:href'
attribute. This setup is functioning properly in both Chrome and Firefox, however, it is not working in Safari.
Here is the HTML code:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id='svgId' width="576" height="720" style="outline:auto;" >
<defs>
<pattern id="imgpattern" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse">
<image id="patternImage" xlink:href="" width="20" height="20"></image>
</pattern>
</defs>
<path id="svgpath" stroke="#f000" fill="#ff0000" stroke-width="0.25px" style="fill:url(#imgpattern) !important"></path>
</svg>
This is the corresponding JavaScript code:
$("#patternImage").attr("xlink:href", encodedImage);
$("#patternImage").load(function(){
console.log("Loaded");
});