Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mime::Type extension order changed (.jpg) #71

Closed
Silex opened this issue Sep 26, 2014 · 5 comments
Closed

Mime::Type extension order changed (.jpg) #71

Silex opened this issue Sep 26, 2014 · 5 comments
Assignees
Milestone

Comments

@Silex
Copy link

Silex commented Sep 26, 2014

Hello,

The following code used to return jpg but now returns jpe since a recent upgrade (the offending commit is 60f478c#diff-a391e22c04309238b0bd982369bcfa4fR103)

2.1.1 :003 > MIME::Types.type_for("foo.jpg").first.extensions.first
 => "jpe"

This is a problem because of https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/interpolations.rb#L119-122 which now stores jpegs with a .jpe extension.

I think the library should provide a way to provide a "prefered" extension for a content-type.

@halostatue
Copy link
Member

This has two parts to it:

  1. Provide an official mechanism for providing a preferred extension (or extensions).
  2. Assume that, in some earlier version of mime-types, MIME::Types.map { |k| [ k, k.extensions.first ] if k.extensions.first }.compact returns a value that we can use as that preferred extension, and get it integrated into the type registry.

@Silex
Copy link
Author

Silex commented Sep 27, 2014

Yes. Apparently many packages relying on mime-types assumed 2.

Tell me when you implement a reliable way to select the preferred extension and I'll make a PR for Paperclip.

@halostatue
Copy link
Member

So, I finally got to looking at this. It was a deliberate change in 2.0 (mime/type.rb:224)…and I think it was the right change to make, but I know that this is a problem. Let me think about how to do this a bit further.

I’ve extracted the extension list from 1.25.1 so that I can at least figure out how to put the data in correctly once I’ve got the code figured out.

halostatue added a commit that referenced this issue Oct 6, 2014
halostatue added a commit that referenced this issue Oct 6, 2014
@Silex
Copy link
Author

Silex commented Oct 6, 2014

Thanks!

@halostatue
Copy link
Member

De nada. I may re-sort in 3.0, but by that time I hope to have a better idea of how this should work moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants