diff --git a/layouts/_markup/render-image.html b/layouts/_markup/render-image.html
index 5577736..a5316d9 100644
--- a/layouts/_markup/render-image.html
+++ b/layouts/_markup/render-image.html
@@ -1,34 +1,12 @@
-{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}}
-{{- $Permalink := .Destination | relURL | safeURL -}}
+{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination) -}}
{{- $alt := .PlainText | safeHTML -}}
-{{- $Width := 0 -}}
-{{- $Height := 0 -}}
-{{- $Srcset := "" -}}
{{/* SVG and external images won't work with gallery layout, because their width and height attributes are unknown */}}
-{{- $galleryImage := false -}}
+{{- $galleryImage := and $image.Height $image.Width -}}
-{{- if $image -}}
- {{- $notSVG := ne (path.Ext .Destination) ".svg" -}}
- {{- $Permalink = $image.RelPermalink -}}
-
- {{- if $notSVG -}}
- {{- $Width = $image.Width -}}
- {{- $Height = $image.Height -}}
- {{- $galleryImage = true -}}
-
- {{- if .Page.Site.Params.imageProcessing.content.enabled -}}
- {{- $small := $image.Resize `480x` -}}
- {{- $big := $image.Resize `1024x` -}}
- {{- $Srcset = printf `%s 480w, %s 1024w` $small.RelPermalink $big.RelPermalink -}}
- {{- end -}}
- {{- end -}}
-{{- end -}}
-
-