Secure media and optimized images?

Hi all:

New admin just coming to terms with Discourse. I’ve recently enabled the “enable s3 uploads” and the “secure media” features in my 2.6.0.beta4 installation. it appears to be working – I can upload images and they are served from s3 with an expiry token set (was expecting them to get served from a URL on my discourse server, but that appears to only be the case for non-image uploads).

I say it appears to be working, however it doesn’t seem to be working exactly how it did when I was using a local store for image uploads. In particular, the “optimized” functionality doesn’t seem to be working. Pardon me if I’m using the incorrect terms here, I’m still learning. But basically, pre-migration to s3/secure settings, I’d see the behavior where the “lightbox” functionality was utilized and you’d be served a smaller image in a responsive lightbox frame, and you could choose to see the original image if you so wished.

Now it doesn’t seem like the optimized images are made, with the exception of avitar images. But when making a new post, when a user uploads an image, it just stores the image in /original/1x and there’s no corresponding optimized images created in /optimized/1x. And so when viewing the post, there’s just a simple image embed to the original image.

Is this correct behavior when configured this way? I haven’t been able to find a post that addresses this directly, and haven’t seen anyone else complaining about it. Any information someone could provide would be appreciated.

1 Like

I’m wondering if the question I asked is a FAQ or I asked it in a unclear way. Can anyone spot any problems with what I’m asking, if it’s not clear what I’m trying to achieve?

1 Like

Your question is clear and searching for “secure media optimized images” on Meta isn’t returning any useful results, so it’s not a FAQ.

I am not sure how optimized images are intended to be handled when the secure media setting is enabled. We’ll need to wait for someone with more knowledge about how it is expected to work to respond.


Thanks for the reply Simon. I’m wondering what steps I could take to debug this further. I guess I might have to spin up a new instance and do a fresh install, and then i can play around with the options and see what happens. At this point, I’m not even sure if moving to s3 storage broke it or if enabling secure media did.

Obviously I could look at the source code too but as it’s an entire stack that is pretty unfamiliar to me, sounds like that might be a longer process.

Note that secure media is a very complex, expert level feature. So you should expect… challenges.


Hi Jeff,

Yes I read those warning when I set it up. But the actual configuration seemed pretty straightforward and went smoothly. Is there more complexity to the configuration than is covered in that document?

My forum is already up and in the air, seems to be going well except for this one thing, and I’m not even sure if that’s just how things work when secure media is enabled.

If I wanted to increase my knowledge and get my arms around that complexity you speak of, could you point me in the right direction? I’m new to discourse (and, well, Rails apps in general), but I’ve quite a bit of experience developing on and maintaining cloud-based systems.

@martin is the resident expert on it.

1 Like

I just tried this out, and with secure media set up and everything my large image upload is working fine, and 5 optimized images are created with the correct security. Looking at how these are generated, I am wondering if your responsive_post_image_sizes or create_thumbnails site setting has been changed?

Do you get the Lightbox at all when you upload an image that is too large and should be optimized? Note that if an image is too small it will not get optimized images generated for it.


Hi martin,

Both responsive_post_image_sizes and create_thumbnails are set to their defaults ([1, 1.5, 2] and true, respectively).

I uploaded this image with a resolution of 7680x4320, and I can see that the original is correctly stored in my s3 /orginal/1x folder AND there is an optimized version stored in /optimized/1x with a resolution of 1024x576. So that’s encouraging; previously I had said the images weren’t created in /optimized/1x and that appears to be incorrect.

However, when I view the post on either PC or mobile, in either Chrome or Firefox, I see that the image from /original/1x is embedded in the post. Here’s an inspection of that image:

(note: I have redacted my site’s domain from this screenshot, i also have DISCOURSE_RELATIVE_URL_ROOT set to /forum so that’s why you have /forum/ in that image src URL.)

So that’s what I’m seeing. Would you have any next steps I could attempt to debug further? Thanks so much for looking into this @martin. I really appreciate it.