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
d3db7a1c
Commit
d3db7a1c
authored
Dec 21, 2011
by
Jim Ryan
Committed by
Jon Yurek
Jan 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process :original style before all other styles
parent
9fb92553
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
lib/paperclip/attachment.rb
+14
-11
test/attachment_test.rb
+14
-0
No files found.
lib/paperclip/attachment.rb
View file @
d3db7a1c
...
...
@@ -427,18 +427,21 @@ module Paperclip
end
def
post_process_styles
(
*
style_args
)
#:nodoc:
styles
.
each
do
|
name
,
style
|
begin
if
style_args
.
empty?
||
style_args
.
include?
(
name
)
raise
RuntimeError
.
new
(
"Style
#{
name
}
has no processors defined."
)
if
style
.
processors
.
blank?
@queued_for_write
[
name
]
=
style
.
processors
.
inject
(
@queued_for_write
[
:original
])
do
|
file
,
processor
|
Paperclip
.
processor
(
processor
).
make
(
file
,
style
.
processor_options
,
self
)
end
end
r
escue
PaperclipError
=>
e
log
(
"An error was received while processing:
#{
e
.
inspect
}
"
)
(
@errors
[
:processing
]
||=
[])
<<
e
.
message
if
@options
[
:whiny
]
post_process_style
(
:original
,
styles
[
:original
])
if
styles
.
include?
(
:original
)
&&
(
style_args
.
empty?
||
style_args
.
include?
(
:original
))
styles
.
reject
{
|
name
,
style
|
name
==
:original
}.
each
do
|
name
,
style
|
post_process_style
(
name
,
style
)
if
style_args
.
empty?
||
style_args
.
include?
(
name
)
end
end
def
post_process_style
(
name
,
style
)
#:nodoc:
begin
r
aise
RuntimeError
.
new
(
"Style
#{
name
}
has no processors defined."
)
if
style
.
processors
.
blank?
@queued_for_write
[
name
]
=
style
.
processors
.
inject
(
@queued_for_write
[
:original
])
do
|
file
,
processor
|
Paperclip
.
processor
(
processor
).
make
(
file
,
style
.
processor_options
,
self
)
end
rescue
PaperclipError
=>
e
log
(
"An error was received while processing:
#{
e
.
inspect
}
"
)
(
@errors
[
:processing
]
||=
[])
<<
e
.
message
if
@options
[
:whiny
]
end
end
...
...
test/attachment_test.rb
View file @
d3db7a1c
...
...
@@ -5,6 +5,20 @@ require 'paperclip/attachment'
class
Dummy
;
end
class
AttachmentTest
<
Test
::
Unit
::
TestCase
should
"process :original style first"
do
file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"50x50.png"
),
'rb'
)
rebuild_class
:styles
=>
{
:small
=>
'100x>'
,
:original
=>
'42x42#'
}
dummy
=
Dummy
.
new
dummy
.
avatar
=
file
dummy
.
save
# :small avatar should be 42px wide (processed original), not 50px (preprocessed original)
assert_equal
`identify -format "%w" "
#{
dummy
.
avatar
.
path
(
:small
)
}
"`
.
strip
,
"42"
file
.
close
end
should
"handle a boolean second argument to #url"
do
mock_url_generator_builder
=
MockUrlGeneratorBuilder
.
new
attachment
=
Paperclip
::
Attachment
.
new
(
:name
,
:instance
,
:url_generator
=>
mock_url_generator_builder
)
...
...
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