strapi-plugin-placeholder icon indicating copy to clipboard operation
strapi-plugin-placeholder copied to clipboard

fix: v5 ready + s3 private buckets support

Open Zharkan opened this issue 1 year ago • 5 comments

Fix: https://github.com/WalkingPizza/strapi-plugin-placeholder/issues/20

Zharkan avatar Sep 29 '24 14:09 Zharkan

@WalkingPizza Can you take a look when you've got enough time please, it can fix : https://github.com/WalkingPizza/strapi-plugin-placeholder/issues/20

Zharkan avatar Jan 11 '25 14:01 Zharkan

One more tweak for this pull request. I've tested v5 version locally and found out that this file https://github.com/Gaylord-Julien/strapi-plugin-placeholder/blob/v5/server/src/pluginId.ts should have a different name:

export const PLUGIN_ID = 'placeholder';

Otherwise this piece of code fails to find the service (https://github.com/Gaylord-Julien/strapi-plugin-placeholder/blob/v5/server/src/utils.ts):

const getService = <ServiceName extends keyof PluginServices>(
  strapi: Core.Strapi,
  serviceName: ServiceName
): PluginServices[ServiceName] => {
  return strapi.plugin(PLUGIN_ID).service(serviceName); // <-- this will fail
};

dmitrysmagin avatar Jan 16 '25 10:01 dmitrysmagin

Also, changes for private buckets are questionable. In my project I had to revert to original code which uses the current provider for the uploads:

const placeholder = ({ strapi }: { strapi: Core.Strapi }) => {
  return {
    async generate(url: string): Promise<string | null> {
      try {
        const settings = getService(strapi, 'settings').get();
        const { base64 } = await getPlaiceholder(url, settings);
        return base64;
      } catch (error) {
        strapi.log.error(error);
        return null;
      }
    },
  };
};

The code above is sufficient. Tried both with local provider and AWS S3 configured for the Media Library - it works, no need for additional S3 handling

dmitrysmagin avatar Jan 16 '25 16:01 dmitrysmagin

@WalkingPizza can you merge this please?

douwepausma avatar Mar 11 '25 15:03 douwepausma

@WalkingPizza - can you please merge this release and make a new version? Or let me know how I can do this?

daandegooijer avatar Jun 17 '25 06:06 daandegooijer