Conversation
get and update media endpoints
|
cc @mcsf @gravityrail if we're missing anything major for a Jetpack enpoint |
|
Something that we have to achieve is to be able to upload a new image without creating a new record into of dB. As far as I see we should split the request into two requests. First one to upload the new image and the second one to update the image-post record. For this reason, I think we should create a new Jetpack action, for instance, So the |
|
I wonder if we can modify |
|
😅 Sorry about that Miguel |
|
Removing the milestone until this is completed-- please feel free to move it back into the appropriate milestone when it's out of "In Progress" |
|
Closing this for now, feel free to reopen if it ever gets fresh attention |
|
Starting to work on this again. |
d3ffed6 to
f89ed2f
Compare
_inc/lib/class.media.php
Outdated
There was a problem hiding this comment.
This var is not used anywhere?
_inc/lib/class.media.php
Outdated
There was a problem hiding this comment.
Unfortunately we need to support PHP 5.2.4 :(
Anonymous functions were introduced in 5.3
There was a problem hiding this comment.
Looks like this may not be defined if there's no $attrs['alt'] set.
There was a problem hiding this comment.
Yes, that's right. I've decided to implement the same behavior that we already do with other endpoints which is silence these errors when these metadata aren't updated, like here: https://github.com/Automattic/jetpack/blob/master/json-endpoints/class.wpcom-json-api-update-media-v1-1-endpoint.php#L41
We still returning an error when the media item updating (post) fails.
There was a problem hiding this comment.
do we need $media_id param?
There was a problem hiding this comment.
yup, If I'm not wrong it's needed to update the media item (post object).
$insert['ID'] = $media_id;
$update_action = wp_update_post( (object) $insert );There was a problem hiding this comment.
You can remove this block -- it should only be added to wpcom as it tells our syncing script to omit it when building out the commits.
There was a problem hiding this comment.
Yeah, it's confusing. tl;dr this @hide-in-jetpack tells a script that we use to hide this block from Jetpack and it's safe to remove from this PR.
Anyway, it's fine to leave it in too. Not a blocker.
_inc/lib/class.media.php
Outdated
There was a problem hiding this comment.
Let's namespace this Jetpack_
_inc/lib/class.media.php
Outdated
There was a problem hiding this comment.
I think this may have been left in...
There was a problem hiding this comment.
🤦♂️ already removed
a3e2408 to
8b882c6
Compare
8b882c6 to
9941c20
Compare
|
This is working well for me. And although github says changes requested, it looks like the changes @dereksmart asked for are handled. So if it looks good to him, I think this is good to 🚢 |
dereksmart
left a comment
There was a problem hiding this comment.
I'm happy :) merging!
|
I'm happy too. :-D |
* Changelog: update stable tag and move changelog to changelog.txt Also remove old releases from readme.txt to keep the changelog tab short. * Changelog: add #5883 Also update the filter's docblock to match new version. * Changelog: add #5938 * Changelog: add #6298 * Changelog: add #3405 * Changelog: add #5941 * Changelog: add #6239 * Changelog: add #6281 * Changelog: add #6303 * Changelog: add #6018 * Changelog: add #6300 * Changelog: add #6296 * Changelog: add #6130 * Changelog: add #6292 * Readme: remove extra "on". * Changelog: add #6307 * Changelog: add #3297 * Changelog: add #6275 * Changelog: add #6321 * Changelog: add #6297 * Readme: update the support forum link anchor. Anchor changed when WordPress.org forums were updated to bbPress 2 * Readme: update list of a12s, it wasn't up to date anymore! * Changelog: add #6338 * Changelog: add #6337 * Changelog: add #6335 * Changelog: add #6333 * Testing List: first version of the 4.7 testing list. * Changelog: add #6332 * Changelog: add #6325 * Changelog: add #6326 * Changelog: add #6339 * Changelog: add #6342 * Changelog: add #6343 * Changelog: add #6346 * Changelog: add #6347 * Changelog: add #6279 * Changelog: add #6306 * Changelog: add #6312 * Changelog: add #6316 * Changelog: add #6171 * Changelog: add #6317 * Changelog: add #6246 * Changelog: add #6263 * Changelog: add #4220 * Changelog: add #5888 * Changelog: add #3406 * Changelog: add #3637 * Changelog: add #6320 * Changelog: add #5992 * Changelog: add #6322 * Changelog: add #6324 * Changelog: add #6352 * Changelog: add #6355 * Changelog: add #6360 * Changelog: add #6362 * Changelog: add #6369, #6382 * Changelog: add #6370 * Changelog: add #6375 * Changelog: add #6383 * Changelog: add #6384 * Changelog: add #6386 * Changelog: add #6395 * Changelog: add #6403 * Changelog: add #6406 * Changelog: add #6418 * Changelog: add #6419 * Changelog: add #6434 * Changelog: add #6446 * Changelog: add #6006 * Changelog: add #6096 * Changelog: add #6399 * Changelog: fix typo. @see #6331 (comment) * Changelog: add #6440 * Changelog: add #6443 * Changelog: add #6445 * Changelog: add #6463 * Changelog: add #6468 * Changelog: add #6471 * Changelog: add #6474 * Changelog: add #6480 * Changelog: add #6497 * Changelog: add #6499 * Changelog: add #6514 * Changelog: add #6267 * Changelog: add #5940 * Changelog: add #6492 * Changelog: add #5281 * Changelog: add #6327 * Changelog: add #6451 * Changelog: add #6525 * Changelog: add #6530
|
yay! |
This PR adds new versions of
get-mediaendpoint and add the newedit-mediaendpoint to the WP COM API.Changes proposed in this Pull Request:
Add v1.2
[POST]/sites/$site/media/$mediaID/editThe
edit-mediaendpoint was added into the WP COM API a while ago. This patch adds the needed code to support theedit-mediaendpoint now for Jetpack sites.The hardest part of this process is to detect when a media item should be added (
new-mediaendpoint) or when it should be updated (edit-mediaendpoint).The right action to take depends on the action parameter into the request body. it could be
jetpack_upload_action(the only one action used at the moment) andjetpack_update_action. When the action is the last one, the attached metadata of the media item is updated according to the new uploaded media file instead of creating a new media item.Also, other tasks are done in this editing process, such as store the original media file, keep the revision history, clean the remaining files when the media item is deleted, etc.
Add v1.2
[GET]/sites/$site/media/$mediaIDThere aren't significant changes in this endpoint. It just adds some fields to the response body.