getAttachmentFolderPathSyncOrNull
Retrieves the attachment folder path for a given note synchronously, when that is possible at all.
Obsidian builds its file/folder context menus and evaluates a command’s checkCallback synchronously, so a caller deciding whether to merely offer a command cannot await getAttachmentFolderPath. This is the synchronous twin such a caller can use instead.
The answer is null when it is not knowable synchronously — that is, when a plugin installed GetAvailablePathForAttachmentsFunctionExtended.extended and therefore owns the resolution, which is genuinely asynchronous. null means “ask getAttachmentFolderPath”, never “there is no attachment folder”. Otherwise the answer is exact rather than a guess: it is produced by the very same code getAttachmentFolderPath runs, whose only asynchronous step — creating a missing attachment folder — is unreachable on this path.
There is deliberately no context parameter: AttachmentPathContext only ever reaches an GetAvailablePathForAttachmentsFunctionExtended.extended override, and this function answers null whenever one is installed.
Import:
import { getAttachmentFolderPathSyncOrNull } from 'obsidian-dev-utils/obsidian/attachment-path';Signature:
function getAttachmentFolderPathSyncOrNull(params: GetAttachmentFolderPathSyncOrNullParams): string | nullParameters:
| Parameter | Type | Description |
|---|---|---|
params | GetAttachmentFolderPathSyncOrNullParams | Parameters for the get attachment folder path sync or null function. |
Returns: string | null — The attachment folder path, or null when it can only be resolved asynchronously.
Links to this page: