From 336ba7d6fe22261c1742135a49579d6e9b1dfb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 26 Jul 2016 13:37:27 +0200 Subject: [PATCH] Attachments: don't always generate new links. Instead, we now just use file_storage.ensure_valid_link(), which takes link expiry into account. --- pillar/application/modules/nodes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pillar/application/modules/nodes.py b/pillar/application/modules/nodes.py index 7212b62a..45208901 100644 --- a/pillar/application/modules/nodes.py +++ b/pillar/application/modules/nodes.py @@ -162,13 +162,14 @@ def item_parse_attachments(response): af['file'] = None continue size = f['size'] if 'size' in f else 'l' + # Get the correct variation from the file + file_storage.ensure_valid_link(f) thumbnail = next((item for item in f['variations'] if item['size'] == size), None) - l = file_storage.generate_link(f['backend'], thumbnail['file_path'], - str(f['project'])) + # Build Markdown img string - l = '![{0}]({1} "{2}")'.format(slug, l, f['name']) + l = '![{0}]({1} "{2}")'.format(slug, thumbnail['link'], f['name']) # Parse the content of the file and replace the attachment # tag with the actual image link field_content = field_content.replace(slug_tag, l)