FEATURE: Support upload:// urls in img tags (#16277)

Previously, our `upload://` protocol urls were only supported in markdown image tags. This meant that our PullHotlinkedImages job was forced to convert `<img` tags to markdown. Depending on the exact syntax, this can actually cause the image to break.

This commit adds support for `upload://` inside regular HTML `<img` tags. In a future commit, we'll be able to use this to make our PullHotlinkedImages job much more robust.

Context at https://meta.discourse.org/t/152801
This commit is contained in:
David Taylor
2022-03-28 16:46:47 +01:00
committed by GitHub
parent fc40a572bb
commit 720e1ca9e7
2 changed files with 128 additions and 54 deletions

View File

@ -1877,6 +1877,12 @@ HTML
![upload](#{upload.short_url.gsub(".png", "")})
Inline img <img src="#{upload.short_url}">
<div>
Block img <img src="#{upload.short_url}">
</div>
[some attachment](#{upload.short_url})
[some attachment|attachment](#{upload.short_url})
@ -1901,6 +1907,10 @@ HTML
</li>
</ul>
<p><img src="#{cdn_url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
<p>Inline img <img src="#{cdn_url}" data-base62-sha1="#{upload.base62_sha1}"></p>
<div>
Block img <img src="#{cdn_url}" data-base62-sha1="#{upload.base62_sha1}">
</div>
<p><a href="#{upload.short_path}">some attachment</a></p>
<p><a class="attachment" href="#{upload.short_path}">some attachment</a></p>
<p><a href="#{upload.short_path}">some attachment|random</a></p>