diff --git a/theme/image.php b/theme/image.php
index e9cc853f81d..c32c5263aa8 100644
--- a/theme/image.php
+++ b/theme/image.php
@@ -84,9 +84,15 @@ if ($rev > 0) {
         image_not_found();
     }
     $cacheimage = false;
+    $imagewithoutsize = preg_replace('/-(?:12|16|24|)+$/', '', $image);
     if ($usesvg && file_exists("$candidatelocation/$image.svg")) {
         $cacheimage = "$candidatelocation/$image.svg";
         $ext = 'svg';
+    }
+    else if ($usesvg && file_exists("$candidatelocation/" . $imagewithoutsize . ".svg")) {
+        $etag = sha1("$rev/$themename/$component/$image");
+        $cacheimage = "$candidatelocation/$imagewithoutsize.svg";
+        $ext = 'svg';
     } else if (file_exists("$candidatelocation/$image.png")) {
         $cacheimage = "$candidatelocation/$image.png";
         $ext = 'png';
@@ -136,7 +142,14 @@ $themerev = theme_get_revision();
 if ($themerev <= 0 or $rev != $themerev) {
     // Do not send caching headers if they do not request current revision,
     // we do not want to pollute browser caches with outdated images.
-    $imagefile = $theme->resolve_image_location($image, $component, $usesvg);
+    $imagefile = '';
+    if ($usesvg && $image != $imagewithoutsize) {
+        $imagefile = $theme->resolve_image_location($imagewithoutsize, $component, $usesvg);
+        $etag = sha1("$rev/$themename/$component/$imagewithoutsize");
+    }
+    if (empty($imagefile) or !is_readable($imagefile)) {
+        $imagefile = $theme->resolve_image_location($image, $component, $usesvg);
+    }
     if (empty($imagefile) or !is_readable($imagefile)) {
         image_not_found();
     }
@@ -154,7 +167,15 @@ make_localcache_directory('theme', false);
 // * if the browser has requested the non-SVG version, we *must* cache _both_ the SVG, and the non-SVG versions.
 
 // First get all copies - including, potentially, the SVG version.
-$imagefile = $theme->resolve_image_location($image, $component, true);
+$imagefile = '';
+if ($usesvg && $image != $imagewithoutsize) {
+    $imagefile = $theme->resolve_image_location($imagewithoutsize, $component, $usesvg);
+    $image = $imagewithoutsize;
+    $etag = sha1("$rev/$themename/$component/$imagewithoutsize");
+}
+if (empty($imagefile)) {
+    $imagefile = $theme->resolve_image_location($image, $component, true);
+}
 
 if (empty($imagefile) || !is_readable($imagefile)) {
     // Unable to find a copy of the image file in any format.
