diff options
Diffstat (limited to 'app/models/concerns/file_attachment.rb')
| -rw-r--r-- | app/models/concerns/file_attachment.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/concerns/file_attachment.rb b/app/models/concerns/file_attachment.rb index 613a6f0..e7a33c5 100644 --- a/app/models/concerns/file_attachment.rb +++ b/app/models/concerns/file_attachment.rb | |||
| @@ -52,6 +52,14 @@ module FileAttachment | |||
| 52 | build_upload_proxy | 52 | build_upload_proxy |
| 53 | end | 53 | end |
| 54 | 54 | ||
| 55 | def has_variant?(style) | ||
| 56 | upload_file_name.present? && File.exist?(file_path(style)) | ||
| 57 | end | ||
| 58 | |||
| 59 | def previewable? | ||
| 60 | has_variant?(:medium) | ||
| 61 | end | ||
| 62 | |||
| 55 | private | 63 | private |
| 56 | 64 | ||
| 57 | def build_upload_proxy | 65 | def build_upload_proxy |
| @@ -106,7 +114,8 @@ module FileAttachment | |||
| 106 | end | 114 | end |
| 107 | 115 | ||
| 108 | def sanitize_filename(filename) | 116 | def sanitize_filename(filename) |
| 109 | File.basename(filename).gsub(/[^\w\.\-]/, '_') | 117 | name = File.basename(filename).unicode_normalize(:nfc) |
| 118 | name.gsub(/(?u)[^\w\.\-]/, '_') | ||
| 110 | end | 119 | end |
| 111 | 120 | ||
| 112 | # Proxy object returned by asset.upload, providing the Paperclip-compatible | 121 | # Proxy object returned by asset.upload, providing the Paperclip-compatible |
