0

I am using WordPress' default REST API for posts. The app also needs images as base64 string. For this, I convert featured image to base64 on the fly. For example, in an API call, 10 posts are being returned. I would loop through posts and convert each featured image to base64 and then inject into the default API. I feel like this approach is not correct and has a lot of overhead cause I am converting images every time. Is there a better way to send images in base64 format. I can think of two other methods but not sure which one is best among the three.

  1. When an image is uploaded convert it to base64 and save the string into the database.

  2. When an image is uploaded convert the image to base64 and then write a text file in the uploads folder that has the base64 code.

OR

  1. Convert the image to base64 in every call. (this is what I am doing right now.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.