jQuery SVG attach background image

by James

HTML

<script src="http://keith-wood.name/js/jquery.svg.js"></script>
<script src="http://keith-wood.name/js/jquery.svgfilter.js"></script>
<link rel="stylesheet" href="http://keith-wood.name/css/jquery.svg.css">
<svg id="pnlShapes" width="640" height="480">
    <svg id="shapes" width="640" height="480">
        <g id="shapes-group" width="640" height="480">
            <polygon id="svgSection_Floor" points="222.61,199.75,222.61,295.19,380.62,295.19,380.62,199.75,222.61,199.75,368.46,283.92,233.54,283.92,233.54,209.12,368.46,209.12,368.46,283.92" title="Floor" link="Primary" style="color: rgb(211, 211, 211); font-size: 0px; left: 0px; top: 0px; opacity: 0.82; fill: rgb(211, 211, 211); cursor: not-allowed;"></polygon>
            <text x="302.61" y="289.4705" fill="white" font-size="9" font-weight="bold" text-anchor="middle">Floor</text>
        </g>
    </svg>
</svg>

JavaScript

$(document).ready(function () {

    var theImg = "https://octodex.github.com/images/octoliberty.png";

    $('#shapes').svg();
    var foo = $('#shapes').svg('get');
    foo.filters.image(null, '', theImg);

});