diff --git a/attachments/admin.py b/attachments/admin.py
index afa789a..2d69f13 100644
--- a/attachments/admin.py
+++ b/attachments/admin.py
@@ -19,7 +19,11 @@ class AttachmentAdmin(admin.ModelAdmin):
js = ["attachments/js/copy_url.js"]
def processed_file_url(self, instance):
- return instance.processed_file.url
+ if instance.processed_file:
+ return instance.processed_file.url
+ return ""
def original_file_url(self, instance):
- return instance.original_file.url
+ if instance.original_file:
+ return instance.original_file.url
+ return ""
diff --git a/attachments/static/attachments/js/copy_url.js b/attachments/static/attachments/js/copy_url.js
index a067f9e..0ac4097 100644
--- a/attachments/static/attachments/js/copy_url.js
+++ b/attachments/static/attachments/js/copy_url.js
@@ -9,7 +9,10 @@ $(document).ready(function() {
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
for (let fileUrl of fileUrls) {
fileUrl = $(fileUrl);
- const existingText = fileUrl.text();
+ const existingText = fileUrl.text().trim();
+ if (!existingText) {
+ continue;
+ }
const copyButton = `📋`;
let innerHTML = `${existingText} ${copyButton}`;
fileUrl.html(innerHTML);