WordPress.org

Ready to get started?Download WordPress

Forums

JSON REST API (WP API)
upload/send media file (2 posts)

  1. jrgd
    Member
    Posted 6 months ago #

    I still have difficulties understanding the doc when it comes to uploading/sending a file to wp via the api. The guide/docs mentions POST /media but it seems a bit short ( https://github.com/WP-API/WP-API/blob/master/docs/routes/media.md )
    would someone be kind enough to share a brief example or some longer explanations on this?
    would be much appreciated—thanks!

    > http://wordpress.org/support/plugin/json-rest-api

    http://wordpress.org/plugins/json-rest-api/

  2. dunar21
    Member
    Posted 6 months ago #

    I don't know where the plugin author has gone to. I'm online looking now at the GSoC Tracker and elsewhere to try and see if he's still working on this project or whether it needs to be taken over by someone else.

    As far as your question, looking at the source, all you need to pass is the file, so posting the file to wp-json/media should get the file inserted into the uploads folder and listed in media attachments. As far as passing additional data, the code uses wp_read_image_metadata.

    So the title and description can be tied into the actual image file's metadata, here's his comment: // use image exif/iptc data for title and caption defaults if possible. If no title is passed that way, the title will be the name of the file.

    I have no idea how to attach this metadata to the file itself. There is some info on how to do it programatically here: http://wordpress.org/support/topic/adding-exif-fields-to-wp_read_image_metadata , but if you are sending the file via the api, this is not what you want. If you figure out more, please post.

Reply

You must log in to post.

About this Plugin

About this Topic