Skip to content
Discussion options

You must be logged in to vote

Good point! You can work around this by directly modifying the attachment's utcDateScheduledForErasureSince property — this is exactly what the internal checkImageAttachments function does.

Update your script to:

const levelNote = api.searchForNote('#levelId=4711');
let html = '';
const attachments = levelNote.getAttachments();

attachments?.forEach(attachment => {
    if (attachment.role === 'image') {
        html += `<img src="api/attachments/${attachment.attachmentId}/image/${attachment.title}">`;
        
        // Mark attachment as used
        attachment.utcDateScheduledForErasureSince = null;
        attachment.save();
    }
});

levelNote.setContent(html);

Setting utcDateSched…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@dosubot
Comment options

@hulmgulm
Comment options

@dosubot
Comment options

Answer selected by hulmgulm
@hulmgulm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant