This example shows how to use CSS media queries with SVG. This color swatches icon has a small and large scale version. If the SVG is inline with the HTML, media queries detecting viewport width will use the width of the window, like you'd expect. In this example, the media query has been included at the top of the SVG element.
But when the same SVG (containing a media query) is used as the source of an img element, the media query can't detect the width of the window... instead the SVG's viewport detects the dimensions of its container—the img element. Notice how the "img SVG" only responds to the width of the img—not the width of the window, like the inline SVG does.