diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-03-27 21:54:44 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-03-27 21:54:44 +0100 |
commit | 7b435fd9bf81265241fab792d8e8e0c2f4f1b619 (patch) | |
tree | ef366f436ed5180489cc9377268e10328fe9a932 /lib/paperclip/attachment_extensions.rb | |
parent | 02f1c04fabab221130de8dfb5611be81825b193b (diff) | |
parent | 6c79b7237e31eb510af7df3f4f2cb133dea39845 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/services/post_status_service.rb`: CW/sensitive logic fixed upstream, but different in glitch-soc. Ported the changes accordingly.
Diffstat (limited to 'lib/paperclip/attachment_extensions.rb')
-rw-r--r-- | lib/paperclip/attachment_extensions.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb index 3b308af5f..d9ec0159a 100644 --- a/lib/paperclip/attachment_extensions.rb +++ b/lib/paperclip/attachment_extensions.rb @@ -24,6 +24,19 @@ module Paperclip flush_deletes end end + + def variant?(other_filename) + return true if original_filename == other_filename + return false if original_filename.nil? + + formats = styles.values.map(&:format).compact + + return false if formats.empty? + + other_extension = File.extname(other_filename) + + formats.include?(other_extension.delete('.')) && File.basename(other_filename, other_extension) == File.basename(original_filename, File.extname(original_filename)) + end end end |