LoaderTest

<?xml version="1.1" standalone="yes"?>
<svg width="19" height="19" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 19 19">
	<image id="loader" />
	<defs>
		<script type="application/ecmascript">
			<![CDATA[
				var url = location.search.match(/[\?\&]url\=([^\&\#]+)/),
					img = new Image();
				if (url) {
					url = decodeURIComponent(url[1]);
					if (url.search(/^(\/\/|https?\:\/\/|data\:image\/(?:jpe?g|png|gif)[\,\;])/) === 0) {
						// relative protocol / http / https / data uri (png, jpg or gif only)
						img.addEventListener("load", function() {
							var w = this.width,
								h = this.height,
								resized, // resized width or height
								H, // resized height
								loader = document.querySelector("#loader");
							if (w >= h) {
								// width is dominant
								resized = 19 * h / w;
								loader.setAttributeNS(null, "y", (19 - resized) / 2);
								loader.setAttributeNS(null, "width", "19px");
								loader.setAttributeNS(null, "height", resized + "px");
							} else {
								// height is dominant
								resized = 19 * w / h;
								loader.setAttributeNS(null, "x", (19 - resized) / 2);
								loader.setAttributeNS(null, "width", resized + "px");
								loader.setAttributeNS(null, "height", "19px");
							}
							loader.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", url);
						});
						img.src = url;
					}
				}
			]]>
		</script>
	</defs>
</svg>