Strapi plugin logo for Media Prefix

Media Prefix

Prepend media urls (images, files, audios, ) with your public url/media prefix on both Admin Panel and API's

thumbnail for Media Prefix

strapi media prefix plugin Logo

Strapi Media Prefix Plugin

Prepend media urls (images, files, audios, ) with your public url/media prefix on both Admin Panel and API's just in response without changing the relative path in database

Prepend media url Screenshot

⚙️ Installation

npm install strapi-plugin-media-prefix
# or
yarn add strapi-plugin-media-prefix

✒️ Plugin Configuration

Enable the plugin by adding the following lines of code in the file: ./config/plugins.ts

1// ./config/plugins.ts
2export default () => ({
3  "media-prefix": {
4    enabled: true,
5  },
6});

or in the file: ./config/plugins.js

1// ./config/plugins.js
2module.exports = {
3  'media-prefix': {
4    enabled: true,
5  },
6};

🌐 Environment Configuration

The plugin can get the public url/media prefix from the .env file or from the server config file: ./config/server.ts if you don't define the MEDIA_PREFIX key in the .env file

🔧 Using .env file for environment configuration

The plugin get the public url/media prefix from .env file using the key MEDIA_PREFIX

so be sure to add MEDIA_PREFIX key in the .env file

#.env
MEDIA_PREFIX=https://kirwako.com/media

🚀 Using ./config/server.ts file for environment configuration

The plugin can also get the public url/media prefix from the server config file: ./config/server.ts if you don't define the MEDIA_PREFIX key in the .env file

so be sure to add url key in the server config file

in the file: ./config/server.ts

1// ./config/server.ts
2export default ({ env }) => ({
3  host: env('HOST', '0.0.0.0'),
4  port: env.int('PORT', 1337),
5  app: {
6    keys: env.array('APP_KEYS'),
7  },
8  url: env('PUBLIC_URL', 'http://localhost:1337'), // be sure to add this line
9});

or in the file: ./config/server.js

1// ./config/server.js
2module.exports = ({ env }) => ({
3  host: env('HOST', '0.0.0.0'),
4  port: env.int('PORT', 1337),
5  app: {
6	keys: env.array('APP_KEYS'),
7  },
8  url: env('PUBLIC_URL', 'http://localhost:1337'), // be sure to add this line
9});

Support

I am very Happy 😀 about every coffee!

Buy Me A Coffee

Install now

npm install strapi-plugin-media-prefix

STATS

4 GitHub stars121 weekly downloads

Last updated

219 days ago

Strapi Version

4.20.0 and above

Author

github profile image for kirwako
kirwako

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.