Shortcodes within shortcodes renders linebreaks as <p>

You are correct; it does not work fine. I made a mistake when testing.

I fixed your shortcode; please pull changes and test again. Here’s a diff:

layouts/shortcodes/img.html
diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html
index eb892ddff..734a45646 100644
--- a/layouts/shortcodes/img.html
+++ b/layouts/shortcodes/img.html
@@ -23,27 +23,25 @@
         sizes="100vw"
         src="{{ $thumbMobile.RelPermalink }}"
         original-src="{{ $image.RelPermalink }}"
-        {{ if (not $noZoom) }}
+        {{- if (not $noZoom) }}
         onClick="zoomImage(this.getAttribute('original-src'))"
         {{ else }}
         class="no-zoom"
-        {{ end }}
->
+        {{ end }}>
     {{ else }}
 <img style="max-width: 100%; max-height: 400px;" alt="{{ $alt }}" src="{{ $src }}" onClick="zoomImage({{ $src }})">
     {{ end }}
 {{ else }}
     {{ if ($image) }}
 <img height="{{ $height }}" width="{{ $width }}" alt="{{ $alt }}" src="{{ $image.RelPermalink }}" original-src="{{ $image.RelPermalink }}"
-        {{ if (not $noZoom) }}
+        {{- if (not $noZoom) }}
         onClick="zoomImage(this.getAttribute('original-src'))"
         {{ else }}
         class="no-zoom"
-        {{ end }}
->
+        {{ end }}>
     {{ else }}
 <img height="{{ $height }}" width="{{ $width }}" alt="{{ $alt }}" src="{{ $src }}"
-        {{ if (not $noZoom) }}
+        {{- if (not $noZoom) }}
         onClick="zoomImage({{ $src }})"
         {{ else }}
         class="no-zoom"

Mixing markdown with raw HTML is complicated; both indentation and blank lines are important.

If you look at the diff above, all we’re doing for each conditional image block is:

  1. Removing one blank line
  2. Making sure that > is not on its own line (that’s markdown syntax for a blockquote)

For shortcodes and render hooks, I usually start every line with {{- so that I don’t have to think about it (much), and I make sure to end the template with either -}} or {{- /**/ -}} to chomp the trailing new line. This is important for inline elements such as images and links to prevent unwanted spacing between adjacent elements.