Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
476084af
Commit
476084af
authored
Jun 22, 2011
by
Sam L'Ecuyer
Committed by
Prem Sichanugrist
Jun 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add selective processing for thumbanils
Closes #499
parent
7a1dbd40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
lib/paperclip/attachment.rb
+3
-1
test/attachment_test.rb
+18
-0
No files found.
lib/paperclip/attachment.rb
View file @
476084af
...
...
@@ -11,6 +11,7 @@ module Paperclip
:url
=>
"/system/:attachment/:id/:style/:filename"
,
:path
=>
":rails_root/public:url"
,
:styles
=>
{},
:only_process
=>
[],
:processors
=>
[
:thumbnail
],
:convert_options
=>
{},
:default_url
=>
"/:attachment/:style/missing.png"
,
...
...
@@ -41,6 +42,7 @@ module Paperclip
@path
=
options
[
:path
]
@path
=
@path
.
call
(
self
)
if
@path
.
is_a?
(
Proc
)
@styles
=
options
[
:styles
]
@only_process
=
options
[
:only_process
]
@normalized_styles
=
nil
@default_url
=
options
[
:default_url
]
@default_style
=
options
[
:default_style
]
...
...
@@ -107,7 +109,7 @@ module Paperclip
@dirty
=
true
post_process
if
@post_processing
post_process
(
*
@only_process
)
if
@post_processing
# Reset the file size if the original file was reprocessed.
instance_write
(
:file_size
,
@queued_for_write
[
:original
].
size
.
to_i
)
...
...
test/attachment_test.rb
View file @
476084af
...
...
@@ -250,6 +250,24 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context
"An attachment with :only_process"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:large
=>
"400x400"
},
:only_process
=>
[
:thumb
]
@file
=
StringIO
.
new
(
"..."
)
@attachment
=
Dummy
.
new
.
avatar
end
should
"only process the provided style"
do
@attachment
.
expects
(
:post_process
).
with
(
:thumb
)
@attachment
.
expects
(
:post_process
).
with
(
:large
).
never
@attachment
.
assign
(
@file
)
end
end
context
"An attachment with :convert_options that is a proc"
do
setup
do
rebuild_model
:styles
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment