Stock images
Content & assetsStock images
Offer stock photos inside the editor through a picker your own server backs.
For your own asset sources, see image libraries.
Stock photos in the embedded editor
The React, Vue, Angular and vanilla packages do not take an Unsplash or Pexels key today. To offer stock photos, point "Open Library" on image and GIF blocks at your own picker with registerCallback("selectImage", ...). Your picker can search a stock provider through your server, so the provider key never reaches the browser.
ts
editor.registerCallback("selectImage", (data, done) => {
// data.kind says which kind of block asked
openStockPicker({ kind: data.kind }).then((photo) => {
done(photo ? { url: photo.url, alt: photo.description } : {});
});
});- Calling
donewith nourl(the person closed your picker) leaves the image as it was. done({ error: "..." })reports a failure to the editor.- Pass
alt; the QA checks warn about an image without alt text.
Uploads from the user's computer go through image uploads instead.