Use MetaData to indicate image download filename


(cpradio) #1

So we’ve had a couple of internal complaints about the fact that the image download name is the sha1 representation and not the actual name of the image (which is available, because you see it in the lightbox). It seems the “actual” name is stored in the metadata of the image.

Is the team open to a PR that retrieves that name and uses it for the download?


Topic details should show real filenames of attachments
Downloading attachments inside in app from a web view
Allow to rename file names of uploaded images
(Jeff Atwood) #2

This has been brought up before, as I recall, it is a difficult change. @zogstrip can you comment? But maybe if it is only inserted when you attempt to download, that will be easier.


(lid) #3

Looking at the way images are handled here on meta.

Images are served via CDN. There is no way you can change the downloaded file name for downloads without routing it via rails first to change the “content-disposition” header.


(Jeff Atwood) #4

That might be ok if the rails routing is only triggered on explicit download, e.g. clicking the download link on the expanded, lightboxed images.

This will not work for right click save as, but then, that might not be the full size image but a thumbnail anyway.


(TechnoBear) #5

On both Firefox and Chromium on Ubuntu Gnome, clicking the download link on the expanded image opens the full-size image in a new tab; it doesn’t open a download dialogue. The only way to download the image is by right-clicking.


(Régis Hanol) #6

The download link of the lightbox will now return the original filename :wink: (requires a rebake for old images)

https://github.com/discourse/discourse/commit/31e9cafe0e053d04fce249a4059bc27ed0772c03


(Jeff Atwood) #9

No repro on Windows, in Firefox when I click the download link (on expanded lightbox) I get a download dialog with the filename thanks to @zogstrip’s latest change:


(cpradio) #10

@zogstrip, we’ve uncovered that this works correctly for images that get “resized” when uploaded due to their large dimensions, but it doesn’t work for images that are below the dimensions requiring the photo to be resized.

Examples;

Works for:

Doesn’t work for:

I suspect because it doesn’t use the lightbox for the download. You have to right click to download the image and that is simply downloading the embeded image (which happens for the larger images too).


(Jeff Atwood) #11

@zogstrip do you think we should light box all images?

This might get weird for tiny images @cpradio think 100 x 100.


(cpradio) #12

Yeah, I’m aware of that. I just can’t think of an easier solution. As the only other solution I can think of is changing how images get rendered and that doesn’t seem like a good idea (and let me be honest, I don’t expect you to do that! – and I wouldn’t ask you to).

Granted what I will say, is I think our instance primarily has images that are “near” the resize threshold but don’t quite meet it, so they are still “large” images, just not large enough to be resized.


(Régis Hanol) #13

Have you considered reducing the threshold?


(cpradio) #14

Before I ask for the wrong setting info, we are talking about the following right?


(Régis Hanol) #15

Yes these are the settings you’re looking for :wink:


(cpradio) #16

The only downside to this suggestion is it would effectively make all thumbnails smaller from now on, right?


(Régis Hanol) #17

Yes, that’s the downside of changing these settings…


(cpradio) #18

So I think the majority of SP are not sold on smaller thumbnails. If we get it on our To Do List to

And if we tie it to a site setting, would Core accept the PR?


(Régis Hanol) #19

Absolutely. Make sure it’s off by default though :wink:


(cpradio) #20

Okay, consider this in our court then. As I don’t see a lot of people requesting this. Also, I can’t guarantee it will get done (SP gets the final say on what our devs work on … who knows, maybe I’ll try this at some point) :wink:


(cpradio) #21

@purldator and @BerryBlue, SP hasn’t done anything with this primarily because it is way low on our list. We’ve been spending time on other things for the time being. I can’t even promise this is a priority for us anymore.