Use absolute links for images

If you upload an image to Discourse through the image button, the URL used in the HTML for the topic is relative.

Other Markdown parsers, like GitHub, instead convert all such URLs to absolute.

This would be helpful when pulling markup through the API, for example, as it means the URLs will continue to work and make sense in any context.

Is it?

Your post shows as:

<p dir="ltr">
  If you upload an image to Discourse through the
  <img src="https://d11a6trkgmumsb.cloudfront.net/original/3X/3/3/334422a7f2abc1e7463a3450ae1834748b842da7.png" alt="image" data-base62-sha1="7jwktUgPUE9mp7Jb4gYTYH5wDYj" width="36" height="34"> 
  button, the URL used in the HTML for the topic is relative.
</p>

which looks absolute for me.

2 Likes

Meta.discourse.org is clearly set up to upload assets to an asset server of some sort. In this case the URL has to be absolute or it wouldn’t work at all.

This is not true for e.g. https://discourse.ubuntu.com/, so I assume it’s not the default. It appears that the default is for assets to be uploaded to the same site and so use a relative URL.

I’m suggesting that relative URLs are never used.

1 Like

So, I’m checking this topic in https://discourse.ubuntu.com/t/ubuntu-desktop-on-raspberry-pi-feedback/18956:

<div class="cooked"><p>We’re delighted to bring Ubuntu Desktop 20.10 to the Raspberry Pi 4, completing the Ubuntu family line-up for Raspberry Pi. We encourage you to try it out and give your feedback so we can continue to improve <img src="https://discourse.ubuntu.com/images/emoji/emoji_one/chart_with_upwards_trend.png?v=9" title=":chart_with_upwards_trend:" class="emoji" alt=":chart_with_upwards_trend:"> Ubuntu, desktop, server and core, on the Raspberry Pi.</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="//ubuntucommunity.s3.dualstack.us-east-2.amazonaws.com/original/2X/5/538181beb312f73b48c34e93c96ec5ca15e98734.jpeg" title="Groovy-Gorilla_WP_1920x1080_RPi.jpg" rel="nofollow noopener"><img src="https://ubuntucommunity.s3.dualstack.us-east-2.amazonaws.com/optimized/2X/5/538181beb312f73b48c34e93c96ec5ca15e98734_2_690x388.jpeg" alt="Groovy-Gorilla_WP_1920x1080_RPi" data-base62-sha1="bUJ61kFOTd09on4dBLyNSmfKJw0" class="d-lazyload" srcset="//ubuntucommunity.s3.dualstack.us-east-2.amazonaws.com/optimized/2X/5/538181beb312f73b48c34e93c96ec5ca15e98734_2_690x388.jpeg, //ubuntucommunity.s3.dualstack.us-east-2.amazonaws.com/optimized/2X/5/538181beb312f73b48c34e93c96ec5ca15e98734_2_1035x582.jpeg 1.5x, //ubuntucommunity.s3.dualstack.us-east-2.amazonaws.com/optimized/2X/5/538181beb312f73b48c34e93c96ec5ca15e98734_2_1380x776.jpeg 2x" width="690" height="388"><div class="meta">
<svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use xlink:href="#far-image"></use></svg><span class="filename">Groovy-Gorilla_WP_1920x1080_RPi.jpg</span><span class="informations">1920×1080 143 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use xlink:href="#discourse-expand"></use></svg>
</div></a></div><p></p>
<p>In the video below, we introduce Ubuntu Desktop for the Raspberry Pi, how to set it up and get cracking.</p>
<p><a href="https://youtu.be/0pT4-RcTERU" class="onebox" target="_blank" rel="nofollow noopener">https://youtu.be/0pT4-RcTERU <span class="badge badge-notification clicks" title="27 clicks">27</span></a></p>
<p>If you prefer, here are tutorials to get you started too:</p>
<p><img src="https://discourse.ubuntu.com/images/emoji/emoji_one/woman_student.png?v=9" title=":woman_student:" class="emoji" alt=":woman_student:"><a href="https://ubuntu.com/tutorials/how-to-install-ubuntu-desktop-on-raspberry-pi-4#1-overview" rel="nofollow noopener">How to install Ubuntu Desktop on Raspberry Pi 4 <span class="badge badge-notification clicks" title="56 clicks">56</span></a></p>
<p><img src="https://discourse.ubuntu.com/images/emoji/emoji_one/man_student.png?v=9" title=":man_student:" class="emoji" alt=":man_student:"><a href="https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#1-overview" rel="nofollow noopener">How to install Ubuntu Server on your Raspberry Pi <span class="badge badge-notification clicks" title="22 clicks">22</span></a></p>
<p><strong>What applications do you want to see on Raspberry Pi?</strong></p>
<p>While the vast majority of the Ubuntu archive is available for ARM devices, not all developers and ISVs publish ARM builds of their software in the <a href="https://snapcraft.io/store" rel="nofollow noopener">Snap Store <span class="badge badge-notification clicks" title="7 clicks">7</span></a> or their respective websites. Comment below to let us know what software you’re missing on Raspberry Pi/ARM that you’d most like to see <img src="https://discourse.ubuntu.com/images/emoji/emoji_one/eyes.png?v=9" title=":eyes:" class="emoji" alt=":eyes:"> made available and we’ll see what we can do.</p>
<p><strong>What HATs are you using?</strong></p>
<p>Raspberry Pi enjoys a rich ecosystem of HATs (Hardware attached on top) and we’re looking to expand the library of available HAT <img src="https://discourse.ubuntu.com/images/emoji/emoji_one/tophat.png?v=9" title=":tophat:" class="emoji" alt=":tophat:"> modules/drivers in Ubuntu over the coming months. Let us know which HATs you’re using in your projects so we can better understand where to prioritise our work.</p>
<p><strong>Other hardware?</strong></p>
<p>Cameras, displays, GPIO, touch screens, USB accessories, and more. How has your experience been using your existing accessories and peripherals for the Raspberry Pi on Ubuntu?</p>
<p><strong>What are you making with Ubuntu on Raspberry Pi?</strong></p>
<p>Finally, show us that you’re using the Ubuntu Desktop on your Raspberry Pi, or what you’re using it for, for a chance to win some free Groovy Gorilla <img src="https://discourse.ubuntu.com/images/emoji/emoji_one/gorilla.png?v=9" title=":gorilla:" class="emoji" alt=":gorilla:"><img src="https://discourse.ubuntu.com/images/emoji/emoji_one/dark_sunglasses.png?v=9" title=":dark_sunglasses:" class="emoji" alt=":dark_sunglasses:"> goodies. Be one of the first to fill out this form: <a href="https://forms.gle/h9wodaFLFYPGps8y6" rel="nofollow noopener">https://forms.gle/h9wodaFLFYPGps8y6 <span class="badge badge-notification clicks" title="38 clicks">38</span></a></p></div>

Those appear to be absolute URLs for me.

I have also tested in a test instance I have without a CDN and it appears to be using absolute URLs too.

We also have this feature request Need relative URLs for uploaded images that is asking the opposite of what you are asking, so I’m really confused here.

1 Like

Ah sorry, maybe it was fixed in a recent upgrade, or something else is going on.

I’ll see if I can reproduce the issue we had and get back to you.

1 Like