Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Front End Performance Optimization Combine and Minify Assets Create a Sprite Map

Sonia Rockett
Sonia Rockett
926 Points

SVG exported from photoshop uses different code using xlink. Can I use this?

The code is very different. It doesn't look like it'll work.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="90" viewBox="0 0 90 90">
  <image id="Layer_0" data-name="Layer 0" x="16" y="14" width="60" height="61" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA9CAMAAADGfvrlAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACN1BMVEUAAAAmp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp98mp981reGM0O7F6PbR7Piy4PRtxOkoqN9FtORtxOo7sOJUuubr9/z////S7fhOt+W54/Wv3/PZ7/na8Pk4ruI6r+Lv+P3w+f0sqeAvquDf8vqq3PL+//9owukwq+Hy+v14yOspqOD2+/6T0+/G6PdWuuZBsuOFzu2c1/DL6vd9yuxAseNDs+M0reHp9vzV7vn9/v8+seOw3/OU1O/8/v7q9vwqqe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ypitON7OViFl94925t+/Pz1+8/ftn+1ljS6e7L2bdYbg/euYr0lee9nVmfA60l43RCrD+N1gLzek9f18vptXqcvWGcMwTvdCNa5SgvGiS4c9s6S/wFmwB6H8WsIOwAAAABJRU5ErkJggg=="/>
</svg>

2 Answers

It's pretty much just inserting an image from a base64 encoded data URI. Think of it like an inline image, instead of getting an image file from somewhere else.

Not very handy in an svg though, since it won't resize nicely like a regular vector would... so the answer is, yes, you could use it, but you probably don't want to (I'm sure there are tons of Twitter svg icons available).

If you have Adobe Illustrator, use that for vector images like svg files. Oh and if using for a production website, you probably want to look at compressing/optimising the svg before using it. Try SVGOMG.

Sonia Rockett
Sonia Rockett
926 Points

@iain. Thanks for your response. I knew it wasn't right, so I ended up using and online converter. Which gave me the correct code.. http://vectormagic.com . NOTE: not all online converters I tried worked as expected. I like the look of SVGOMG will try it out next time I am using SVG's.

If my answer helped, please mark it as 'best answer'. :)