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
f5851f1d
Commit
f5851f1d
authored
Jul 15, 2011
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an option to ThumbnailProcessor to override animated thumbnail generation.
Closes #515
parent
489df170
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
lib/paperclip/style.rb
+2
-2
lib/paperclip/thumbnail.rb
+4
-2
test/thumbnail_test.rb
+18
-0
No files found.
lib/paperclip/style.rb
View file @
f5851f1d
...
...
@@ -72,7 +72,7 @@ module Paperclip
# Supports getting and setting style properties with hash notation to ensure backwards-compatibility
# eg. @attachment.styles[:large][:geometry]@ will still work
def
[]
(
key
)
if
[
:name
,
:convert_options
,
:whiny
,
:processors
,
:geometry
,
:format
].
include?
(
key
)
if
[
:name
,
:convert_options
,
:whiny
,
:processors
,
:geometry
,
:format
,
:animated
].
include?
(
key
)
send
(
key
)
elsif
defined?
@other_args
[
key
]
@other_args
[
key
]
...
...
@@ -80,7 +80,7 @@ module Paperclip
end
def
[]=
(
key
,
value
)
if
[
:name
,
:convert_options
,
:whiny
,
:processors
,
:geometry
,
:format
].
include?
(
key
)
if
[
:name
,
:convert_options
,
:whiny
,
:processors
,
:geometry
,
:format
,
:animated
].
include?
(
key
)
send
(
"
#{
key
}
="
.
intern
,
value
)
else
@other_args
[
key
]
=
value
...
...
lib/paperclip/thumbnail.rb
View file @
f5851f1d
...
...
@@ -2,7 +2,8 @@ module Paperclip
# Handles thumbnailing images that are uploaded.
class
Thumbnail
<
Processor
attr_accessor
:current_geometry
,
:target_geometry
,
:format
,
:whiny
,
:convert_options
,
:source_file_options
attr_accessor
:current_geometry
,
:target_geometry
,
:format
,
:whiny
,
:convert_options
,
:source_file_options
,
:animated
# List of formats that we need to preserve animation
ANIMATED_FORMATS
=
%w(gif)
...
...
@@ -25,6 +26,7 @@ module Paperclip
@convert_options
=
options
[
:convert_options
]
@whiny
=
options
[
:whiny
].
nil?
?
true
:
options
[
:whiny
]
@format
=
options
[
:format
]
@animated
=
options
[
:animated
].
nil?
?
true
:
options
[
:animated
]
@source_file_options
=
@source_file_options
.
split
(
/\s+/
)
if
@source_file_options
.
respond_to?
(
:split
)
@convert_options
=
@convert_options
.
split
(
/\s+/
)
if
@convert_options
.
respond_to?
(
:split
)
...
...
@@ -86,7 +88,7 @@ module Paperclip
# Return true if the format is animated
def
animated?
ANIMATED_FORMATS
.
include?
(
@current_format
[
1
..-
1
])
&&
(
ANIMATED_FORMATS
.
include?
(
@format
.
to_s
)
||
@format
.
blank?
)
@animated
&&
ANIMATED_FORMATS
.
include?
(
@current_format
[
1
..-
1
])
&&
(
ANIMATED_FORMATS
.
include?
(
@format
.
to_s
)
||
@format
.
blank?
)
end
end
end
test/thumbnail_test.rb
View file @
f5851f1d
...
...
@@ -310,5 +310,23 @@ class ThumbnailTest < Test::Unit::TestCase
assert_equal
@thumb
.
transformation_command
.
first
,
"-coalesce"
end
end
context
"with animated option set to false"
do
setup
do
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
:geometry
=>
"50x50"
,
:animated
=>
false
)
end
should
"output the gif format"
do
dst
=
@thumb
.
make
cmd
=
%Q[identify "
#{
dst
.
path
}
"]
assert_match
/GIF/
,
`
#{
cmd
}
`
.
chomp
end
should
"create the single frame thumbnail when sent #make"
do
dst
=
@thumb
.
make
cmd
=
%Q[identify -format "%wx%h" "
#{
dst
.
path
}
"]
assert_equal
"50x50"
,
`
#{
cmd
}
`
.
chomp
end
end
end
end
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