I'm trying to configure Astro so that it wraps all Markdown output <img>s with <a> tags that link to the image directly. (So clicking on an image takes you directly to the source).
I thought creating a rehype plugin was the way to go, but I'm seeing Astro rewrite the img src tags later in the pipeline.
Given a source:

A rehype plugin to wrap with an <a> tag results in something like the following (for prod build):
<a href="./IMG_20250825.jpg"><img alt="alt" loading="lazy" decoding="async" fetchpriority="auto" width="4096" height="3072" src="/_astro/IMG_20250825.CWrw5d7V_1OQslT.webp" ></a>
When my desired outcome is:
<a href="/_astro/IMG_20250825.CWrw5d7V_1OQslT.webp"><img alt="alt" loading="lazy" decoding="async" fetchpriority="auto" width="4096" height="3072" src="/_astro/IMG_20250825.CWrw5d7V_1OQslT.webp" ></a>
(notice the href attribute)
Is there any way to achieve this? I want to essentially execute my rehype plugins AFTER Astro's own rewriting.