Closed tirthbodawala closed 1 year ago
@emil-petras any updates on the above?
@tirthbodawala I confirmed that there is an issue. The query returns null because during image create, it doesn't yet exist. So ideally, there should be a check whether the event is 'beforeCreate'. The same situation doesn't happen in 'beforeUpdate'.
So just add 'eventType' parameter to the function. Add an 'if' that runs the blurhash update only if the event type equals to 'beforeCreate'.
And change the subscribe to this:
strapi.db.lifecycles.subscribe({ models: ['plugin::upload.file'], beforeCreate: (event) => generateBlurhash(event, 'beforeCreate'), beforeUpdate: (event) => generateBlurhash(event, 'beforeUpdate'), });
Solves: https://github.com/emil-petras/strapi-blurhash/issues/7