chladog / payload-webp

payloadcms/payload plugin for automatic image conversion to webp format.
https://www.npmjs.com/package/payload-webp
GNU General Public License v3.0
44 stars 5 forks source link

Does not appear to work with @payloadcms/plugin-cloud-storage #13

Closed lucyawrey closed 1 year ago

lucyawrey commented 1 year ago

Automatic WebP creation on image upload would be very helpful for our project. When I attempt to use this plugin along with the official @payloadcms/plugin-cloud-storage plugin it silently fails. I get no errors, the webp file is not created, and the data looks like this:

{
  "id": "6499eb77760da000386d9d01",
  "webp": {},
  "filename": "TEST.jpg",
  ...
}

I would assume this is not a bug, but that this plugin is only designed to work with local image storage and not the cloud plugin. Is there a way I can make them work together, or is this something you plan to add support for? Thanks!

chladog commented 1 year ago

Support for external plugins is out of scope of this package for now due to lack of time. However you can implement storing it to external storage similarly as it's implemented in @payloadcms/plugin-cloud-storage with newly added hooks feature in WebP Plugin Options. Specifically the afterConversion hook. The parameter contains resulting object including BufferObject of the file.

If you make such a hook in a generalised way I would be happy to merge it to this package as an extra utility that anyone could import and use :-)

ainsleyclark commented 4 months ago

Has anyone implemented this?