German Documentation: Hier gelangst du zur deutschen Dokumentation.
The goal of the Plugin SDK is to simplify plugin development by providing a user interface and minimizing direct communication with our server APIs.
The Plugin SDK must be embedded in an iframe. Users can log in and select files inside the SDK. Once selected, the SDK sends a file list to your plugin. The list contains download links and metadata. Your plugin is responsible for downloading the files.
Because your plugin performs the download, it must report download progress back to the Plugin SDK.
The Plugin SDK is available in 2 languages. Use the language requested by your user:
These steps are sufficient for a working integration:
applicationId.onSdkReady.setAllowedFileTypes, setAllowedDownloadFormats, setButtonText, useDirectLinks).downloadFiles or directLinksCreated.setDownloadProgress, setDownloadComplete, or setDownloadFailed).<iframe
id="pixxio-plugin-sdk"
src="https://plugin.pixx.io/static/v1/en/media?applicationId=YOUR_APPLICATION_ID"
style="width: 100%; height: 100%; border: 0"
></iframe>
const iframe = document.getElementById('pixxio-plugin-sdk');
const sdkOrigin = 'https://plugin.pixx.io';
function sendToSdk(method, parameters = []) {
iframe.contentWindow.postMessage(
{
receiver: 'pixxio-plugin-sdk',
method,
parameters
},
sdkOrigin
);
}
window.addEventListener('message', async (event) => {
if (event.origin !== sdkOrigin) {
return;
}
const data = event.data;
if (!data || data.sender !== 'pixxio-plugin-sdk') {
return;
}
switch (data.method) {
case 'onSdkReady':
sendToSdk('setButtonText', ['Apply selection']);
sendToSdk('setAllowedDownloadFormats', [['original', 'jpg', 'png']]);
break;
case 'downloadFiles': {
const [files] = data.parameters ?? [[]];
await downloadFiles(files);
break;
}
case 'directLinksCreated': {
const [files] = data.parameters ?? [[]];
await processDirectLinks(files);
break;
}
case 'onError': {
const [error] = data.parameters ?? [];
console.error('Plugin SDK Error', error);
break;
}
default:
break;
}
});
async function downloadFiles(files) {
try {
for (let i = 0; i < files.length; i++) {
const file = files[i];
await fetch(file.downloadURL);
const progress = Math.round(((i + 1) / files.length) * 100);
sendToSdk('setDownloadProgress', [progress]);
}
sendToSdk('setDownloadComplete');
} catch {
sendToSdk('setDownloadFailed');
}
}
async function processDirectLinks(files) {
console.log('Received direct links', files);
}
onSdkReadydownloadFiles or directLinksCreatedCommunication uses PostMessage.
interface PluginSdkEvent {
sender: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
interface PluginSdkEvent {
receiver: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
window.addEventListener('message', (event) => {
if (event.origin !== 'https://plugin.pixx.io') {
return;
}
const data = event.data;
if (data.sender === 'pixxio-plugin-sdk') {
switch (data.method) {
case 'downloadFiles':
// Do stuff
break;
...
}
}
});
iframe.contentWindow.postMessage(
{
receiver: 'pixxio-plugin-sdk',
method: 'login'
},
'https://plugin.pixx.io'
);
downloadFilesThe user selected files that your plugin now needs to download.
directLinksCreatedThe user selected files and direct links are provided instead of download URLs.
onSdkReadyThe Plugin SDK is only ready to receive PostMessage events after this event.
Note: Incoming login messages before onSdkReady are ignored.
loginSuccessThe user successfully logged in. Handle this event only if your plugin needs to persist credentials for background sync.
logoutSuccessThe user logged out. If your plugin stores user credentials, remove them.
onErrorAn SDK error occurred. Your plugin can display an error state or notification.
selectionChangeSelection changed (files selected or deselected).
The selected item shape is:
interface SelectedItem {
id: number;
fileName: string;
previewUrl: string;
}
Message shape:
{
receiver: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
Supported methods:
setDownloadProgresssetDownloadCompletesetDownloadFailedloginlogoutsetAllowedFileTypessetAllowedDownloadFormatsshowErrorsetButtonTextuseDirectLinksresetNavigationUse these query parameters to configure the SDK initially:
standaloneLoginEnables separate login flow. If active, the login page does not automatically navigate to the next page and sends login success via PostMessage.
darkEnables dark mode.
allowedFileTypesFilters media views by file extension.
allowedDownloadFormatsRestricts selectable download formats. Supported values: original, preview, jpg, png, pdf, tiff, webp.
applicationId
applicationId is mandatory.
If you do not have an applicationId yet, contact support: support@pixx.io
multiSelectEnables or disables multi-select in media views.
hideLinksHides links in the SDK. Supported values: mediaspace, help.
selectButtonTextSets the primary selection button label.
metadataControls which metadata fields are returned with downloads.
Note: Only values from importantMetadata are returned.
useDirectLinksUses directLinksCreated instead of downloadFiles.
hideSelectionFooterHides the selection footer that shows the number of selected files.
hideAvatarHides the avatar section in the header.
backgroundColorOverrides the SDK background color to better match the host plugin UI.
onSdkReady never arrivesPossible causes:
https://plugin.pixx.io/static/v1/....Fix:
window.addEventListener('message', ...) during app startup.Possible causes:
event.origin check.data.sender === 'pixxio-plugin-sdk' validation.Fix:
https://plugin.pixx.io.event.origin, then data.sender, then data.method.Possible causes:
applicationId in URL.applicationId.Fix:
applicationId as query parameter.applicationId.downloadFilesPossible causes:
Fix:
setDownloadProgress regularly while downloading.setDownloadComplete or setDownloadFailed.Possible causes:
Fix:
allowedFileTypes, allowedDownloadFormats, hideLinks....&allowedFileTypes=jpg&allowedFileTypes=png.