WalkingPizza / strapi-plugin-placeholder

Serve placeholders with your Strapi images
MIT License
29 stars 20 forks source link

Bug: 500 when trying to edit image #3

Closed rpiech closed 2 years ago

rpiech commented 2 years ago

I've stumbled upon an issue when trying to add alternativeText to image, when you try to save it, it will throw 500 error. Uploading works just fine, there's only a problem when you click 'Finish' button in edit of an image. I've already tried your workaround from #2 but it wouldn't work in this case.

@strapi/strapi: "4.2.0" strapi-plugin-placeholder: "^4.1.7"

How to replicate:

  1. Upload an image in media library
  2. Click edit button
  3. Try to save
  4. It should throw 500 error

Zrzut ekranu 2022-07-8 o 11 32 12

Evilazio commented 2 years ago

I created a pacth for this error.

first install this npm i patch-package --save-dev

create a folder named patches in the root and put a file named strapi-plugin-placeholder+4.1.7.patch there with this content:

diff --git a/node_modules/strapi-plugin-placeholder/server/utils.js b/node_modules/strapi-plugin-placeholder/server/utils.js
index afee787..59d836f 100644
--- a/node_modules/strapi-plugin-placeholder/server/utils.js
+++ b/node_modules/strapi-plugin-placeholder/server/utils.js
@@ -8,7 +8,7 @@ const pluginId = require('./plugin-id');
  * @returns {boolean} whether a placeholder can be generated for the given MIME type
  */

-const isValidMimeType = (mimeType) => mimeType.startsWith('image/');
+const isValidMimeType = (mimeType) => mimeType && mimeType.startsWith('image/');

 /**
  * Helper that retrieves one of the available services of this plugin from Strapi.

after this rerun npm i

WalkingPizza commented 2 years ago

@Evilazio can you confirm the placeholder is updated properly when you update a media library entry by replacing the image in it?

arixwap commented 2 years ago

I also face the same issue here

image

Evilazio commented 2 years ago

@Evilazio can you confirm the placeholder is updated properly when you update a media library entry by replacing the image in it?

Yes, the placeholder is updated correctly when replace the image.

WalkingPizza commented 2 years ago

Should be fixed in the new 4.3.6 version!