Open wdmtech opened 8 months ago
Hey, any updates on this topic? Got same issue, strapi 4.21.1
Experiencing the same issue with Strapi 4.20.5 and strapi-plugin-image-optimizer ^2.2.1
same issue here
Hello everyone,
Thanks to all contributors for this project and for the work done.
@marlokessler,
I faced the same issue today and found out that we don't try to register the extension if we use .ts extension for "extensions/upload/strapi-server" file.
I didn't check why it does, but I guess that it might be a bug in strapi code if it worked before.
Versions:
@wdmtech, @tagperfect, @azamatsalamat, @freddieerg,
Disclaimer: I didn't test it very well, but as a temporary solution I guess that you can try to fix the issue this way:
Temporary fix:
'use strict';
const imageOptimizerService = require('strapi-plugin-image-optimizer/dist/server/services/image-optimizer-service').default;
module.exports = (plugin) => { plugin.services['image-manipulation'] = imageOptimizerService(); return plugin; };
It works for me.
**UPDATE:**
I didn't see that I have no support of typescript from the bootstrap of strapi project. To work with config with **.ts** extension of file **extensions/upload/strapi-server** you have to add support of typescript before as described here:
https://docs.strapi.io/dev-docs/typescript#add-typescript-support-to-an-existing-strapi-project
Then you will be able to use it with the following code:
import { Common } from "@strapi/strapi"; import imageOptimizerService from "strapi-plugin-image-optimizer/dist/server/services/image-optimizer-service";
export default (plugin: Common.Plugin) => { plugin.services["image-manipulation"] = imageOptimizerService();
return plugin; };
Wow, thanks for looking into this @echolimazulu. Super helpful!! :)
Package versions
Strapi version: "4.13.6" strapi-plugin-image-optimizer version: "^2.1.1"
The issue
I wasn't able to get the plugin to work with my current project (stuck on older version since other plugins require updating), so I created a brand new Strapi project with
npx create-strapi-app@4.13.6
(the same version my current project is running)However I see the same issue even on a clean project.
Someone else in Discord is experiencing this issue too (although they don't specify their Strapi version)
Reproduction
Created the project, then I added the override file at
src/extensions/upload/strapi-server.ts
I created a new
plugins.js
file atconfig/plugins.js
to contain the example config settings provided in README.MDI ran
npm run build
and thennpm run develop
I can see that the plugin is loaded in the Plugins section of the Admin panel
Uploaded a jpg image with fairly large dimensions (photo size)
Queried the asset, observed that only the default Strapi media sizes are available, and the file is in its original format
I think that's all the steps followed correctly, maybe not? :-D
Any help appreciated. Any idea what I might be doing wrong?