WalkingPizza / strapi-plugin-placeholder

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

[Feature Request] Generate placeholders for previously uploaded images #1

Closed EGGamer closed 1 year ago

EGGamer commented 2 years ago

It would be nice if the plugin had a button to generate placeholders for already uploaded images before the plugin was installed (or if it did it automatically). Otherwise, we need to re-upload them and in large-scale projects it might not be easy

WalkingPizza commented 2 years ago

Hey @EGGamer! It's a very nice idea, so it'll be there eventually, I just have to figure out the most performant way of doing it!

niklasfjeldberg commented 2 years ago

@WalkingPizza any update on this?

WalkingPizza commented 2 years ago

Apologies for the delay.

You can now do this by copying this gist into your ./database/migrations folder and starting your Strapi instance!

It basically retrieves BATCH_SIZE files at a time, making sure to only retrieve those that have a mime type starting with image/, a URL and no placeholder value, and then tries to generate and update the placeholder.

Let me know if it works!

RilDev commented 2 years ago

It worked for me, thanks!

eso519 commented 2 years ago

Apologies for the delay.

You can now do this by copying this gist into your ./database/migrations folder and starting your Strapi instance!

It basically retrieves BATCH_SIZE files at a time, making sure to only retrieve those that have a mime type starting with image/, a URL and no placeholder value, and then tries to generate and update the placeholder.

Let me know if it works!

Works nicely. Thank you!

ghost commented 1 year ago

A couple of important details:

Hope this helps someone!

yasssuz commented 1 year ago

Closing issue as feature was implemented and README was updated https://github.com/WalkingPizza/strapi-plugin-placeholder/pull/5