The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

upload/send media file (2 posts)

  1. jrgd
    Posted 2 years 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


  2. aryanduntley
    Posted 2 years 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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic