This is a Directus extension that encodes uploaded images in base64 format. The extension takes an image file as input and returns its base64 encoded string.
To install this extension, follow these steps:
- Clone the repository to your local machine.
- Navigate to the repository directory.
- Run
npm installto install the required dependencies. - Copy the entire repository folder to the
/extensions/customfolder of your Directus installation.
To use the extension, follow these steps:
- Navigate to your Directus project.
- Go to the settings page of the collection where you want to enable the extension.
- Click on the "Extensions" tab.
- Enable the "Base64 Image Encoder" extension.
- Click on the "Save" button to save the changes. After enabling the extension, uploaded images in the collection will be automatically encoded in base64 format.
This extension does not require any configuration.
To develop this extension further, follow these steps:
- Clone the repository to your local machine.
- Navigate to the repository directory.
- Run
npm installto install the required dependencies. - Run
npm run devto start the development server. - Make changes to the code as necessary.
- Test the changes by uploading an image in the collection where the extension is enabled.
- Commit the changes and create a pull request.
This extension depends on the following packages:
@directus/extensions-sdkpathsharp
- Explain why sharp path is Harcoded
const sharp = require("/directus/node_modules/sharp");spoiler: it's because we need to use sharp installed by directus - Explain how using it in a flow
- Publish a package
- npmjs.com
- npm.pkg.github.com
- CI/CD
This extension is licensed under the MIT License. See the LICENSE file for more information.