Directus extension hook to get svg code from svg files
Steps:
- First install the package "npm install directus-custom-hook-svg-to-code"
- create a file "extensions/hooks/svg-to-code/index.js"
- put
var e = require('directus-custom-hook-svg-to-code'); module.exports = e;
in that index.js file - Start directus.
- Go to Settings>Data Model>System Collections(drop down)>Directus Files
- Create a new field with key "svg_code" and type "text". Also, make this field read only.
- Now when you upload an svg file, this field will immediately be filled with the svg code for that file.