WP API – images uploaded as attachments but not displaying
-
I have uploaded posts using the API and the post is created successfully. I use the post with the ‘media’ parameter to upload the images.
– The images are visible at /wp-admin/upload.php and it reports ‘Uploaded to’ <The title of the post> and I have the option to ‘detatch’.
– When I request post info I can see the images are defined in the post as attachmentsHowever the images are not displayed in the post. I have no ide why they are not displaying as everything looks good.
At the description for
https://public-api.wordpress.com/rest/v1/sites/$site/posts/new
Request parameter: “media:
An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available.”The blog I need help with is: (visible only to logged in users)
-
I managed to get the attached images to display in the post…
I believe the problem was that I previously defined a title for the image.
–form ‘media_attrs[0][title]=test title’
If I don’t do this, by default the title is the name of the image. So by changing the title from the name of the image, I guess I broke a link somewhere.
This worked…
`curl -v –http1.1
–form ‘title=Post Title’
–form ‘content=Image Post’
–form ‘tags=test’
–form ‘status=publish’
–form ‘format=gallery’
–form ‘media[0]=@<path>/IMG_6835.JPG’
–form ‘media[1]=@<path>/IMG_6370.JPG’
-H ‘Authorization: BEARER <Oauth2 token>’
‘https://public-api.wordpress.com/rest/v1.1/sites/seedstewart.wordpress.com/posts/new’
- The topic ‘WP API – images uploaded as attachments but not displaying’ is closed to new replies.