Wrong image size for non-Gravatar avatars in network graph
Created by: zeeZ
Users with gravatar images are scaled correctly in the network graph, non-gravatar users have their avatar image used at full size, showing only the top left corner of the image in the graph.
In the generated SVG defs, a gravatar icon looks like this:
<pattern id="..." x="0" y="0" patternUnits="userSpaceOnUse" height="20" width="20" patternTransform="matrix(1,0,0,1,0,0) translate(230,460)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><image x="0" y="0" xlink:href="http://www.gravatar.com/avatar/0bbde2afaa25d3bceacd2a0b5598fbaf?s=20&d=mm" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" width="20" height="20"></image></pattern>
Any other icon looks like this:
<pattern id="..." x="0" y="0" patternUnits="userSpaceOnUse" height="300" width="300" patternTransform="matrix(1,0,0,1,0,0) translate(230,10)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><image x="0" y="0" xlink:href="/uploads/user/avatar/2/google.png" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" width="300" height="300"></image></pattern>
Dimensions (width, height) in both <pattern/>
and <image/>
are set to the image's actual size. This works for Gravatar images since the image requested already has the proper dimensions to fit the rect in the graph. Manually changing the dimensions in defs for both <pattern/>
and <image/>
to 20px for uploaded images makes them look correct in the graph.
Sadly, I do not know where those defs are generated from, so it'd be up to someone else to set all image dimensions to a fixed size instead of using their actual values.