baranovskypd/goodpress

Improve media upload

Opened this issue ยท 2 comments

Current workflow that works but could be improved because it's so fragile

  • I delete all media associated to a post and re-upload everything when I update the post.

  • No longer true ๐ŸŽ‰ I also change src of img in the post by using regex (from the relative reference created by rmarkdown to an absolute URL I got from the API after uploading the image) and it should be XPat stuff.

In each folder after the first upload maybe keep track of post ID and hash+name of figures, in .wordpress.yml, in order to see

  • whether the post should be created or updated
  • whether an image needs to be created or updated

Since images are now uploaded with the post as parent, I could also list existing images (in the WordPress gallery) that have the post as parent, and remove those that are no longer needed.

It is very important to not keep old files, because bloating the gallery doesn't sound like a good idea.

Juggling files through the WP REST API is beyond me but just want to report that the first point in OP doesn't seem to be what happens now: I iterated over a couple versions of a post and did get my gallery bloated. Would be happier with the (brute force) method of deleting, then re-adding everything.