diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html
index 09e23181..c918247b 100644
--- a/layouts/partials/textprocessing.html
+++ b/layouts/partials/textprocessing.html
@@ -77,9 +77,31 @@
{{$href := printf "/%s/%s" $dirname $basename}}
{{if (hasPrefix . "!")}}
- {{$width := index $split 1}}
- {{$link := printf "" $href (default "auto" $width)}}
- {{$content = replace $content . $link}}
+ {{ $embed_ext := lower (path.Ext $href) }}
+
+ {{if in ".png .jpg .jpeg .gif .bmp .svg" $embed_ext }}
+ {{$width := default "auto" (index $split 1) }}
+ {{$link := printf "" $href $width}}
+ {{$content = replace $content . $link}}
+
+ {{else if in ".mp4 .webm .ogv .mov .mkv" $embed_ext}}
+ {{$link := printf "" $href}}
+ {{$content = replace $content . $link}}
+
+ {{else if in ".mp3 .webm .wav .m4a .ogg .3gp .flac" $embed_ext}}
+ {{$link := printf "" $href}}
+ {{$content = replace $content . $link}}
+
+ {{else if in ".pdf" $embed_ext }}
+ {{$src_link := printf "[source]" $href}}
+ {{$iframe_link := printf "" $href}}
+ {{$link := printf "%s
%s" $src_link $iframe_link}}
+ {{$content = replace $content . $link}}
+
+ {{else}}
+ {{$link := printf "%s" $href $href}}
+ {{$content = replace $content . $link}}
+ {{end}}
{{else}}
{{$link := printf "%s" $href $display}}
{{$content = replace $content . $link}}