Default set of mime types

116 views
Skip to first unread message

Jean-Philippe

unread,
Dec 31, 2008, 5:26:48 AM12/31/08
to Paperclip Plugin
Hello,

First, thanks for this plugin and the constant updates to it !

A feature I'd like to see in paperclip is a set of mime types,
matching some types of file.
Here is an example of the typical use case (as I don't think i'm
really clear):

class User < ActiveRecord::Base
has_attached_file :avatar
validates_attachment_content_type :avatar, :content_type => :image
end

or something along
validates_attachment_content_type :avatar, :content_type =>
Paperclip::MimeTypes::Image

with Paperclip::MimeTypes::Image being == ['image/jpeg', 'image/
pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg']
Other 'sets' of mime types being 'video', 'document' (Word, OO.org,
PDF etc) for exemple.

I think this could be a nice way to avoid duplication and missing mime
types.
Could this be added in some way in paperclip ?

Thanks (and happy new year :-) )

Jonathan Yurek

unread,
Dec 31, 2008, 9:37:31 AM12/31/08
to papercli...@googlegroups.com
You know, I'd resisted this idea when presented as the ":content_type
=> :image" way, but having a few constants that contain an array of
content types seems way more palatable to me, because it's much more
transparent what's going on (and therefore modifiable). I think will
add this fairly soon.

Thanks for the idea.
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

Jean-Philippe

unread,
Jan 8, 2009, 6:06:00 AM1/8/09
to Paperclip Plugin
Thanks for listening to this suggestion, I'm sure this will be useful.

(But indeed after some thoughts the symbol idea isn't that clean)

Chad Pytel

unread,
Jan 8, 2009, 8:41:11 AM1/8/09
to papercli...@googlegroups.com
The mime types built into Rails have the ability to define synonyms
and such. If we're exploring something here, it's probably worthwhile
to look into using those.

-Chad
---
Chad Pytel, Founder and CEO
thoughtbot, inc.
organic brains. digital solutions.
-------------------------------------------
tel: 617.482.1300 x113
fax: 866.217.5992
http://www.thoughtbot.com




linojon

unread,
Jul 3, 2009, 2:00:42 AM7/3/09
to papercli...@googlegroups.com
i know this is an old thread but thought i'd point out this seems to
work

validates_attachment_content_type :image, :content_type => /image/



On Jan 8, 2009, at 6:06 AM, Jean-Philippe wrote:

>
Reply all
Reply to author
Forward
0 new messages