Question:
Why is my cover image width and height are not set when creating a media then a post thanks to the API? Then it leads to the impossibility of showing the image properly.
Product:
API
What are you trying to achieve:
I am uploading an image file thanks to the API, then I am creating a draft post thanks to the api and i am specifying the media (previously upload) id. When i go to the blog post panel, the image is well featured in the settings of the post. But then when I preview my blog post lists, the hero image is bugged, indeed in their URL there is w_NaN and h_NaN
Like this
https://static.wixstatic.com/media/image_id/v1/fill/w_NaN,h_NaN,fp_0.50_0.50,lg_1,q_90,enc_auto/###
but after going back to the blog post panel, in the settings, if I attribute the exact same image in the modal, then no bug.
So what I am missing here with the API call?
Moreover, when creating the post, in the response the width and height of the post are set to 0.
Summary
{
"draftPost": {
"id": "###",
"title": "###",
"featured": false,
"categoryIds": [],
"coverMedia": {
"enabled": true,
"image": {
"id": "###~mv2.jpg",
"url": "https://static.wixstatic.com/media/###~mv2.jpg",
"height": 0,
"width": 0,
"filename": "###.jpg"
},
"displayed": true,
"custom": false
},
"memberId": "###",
"hashtags": [],
"commentingEnabled": true,
"minutesToRead": 5,
"heroImage": {
"id": "###~mv2.jpg",
"url": "https://static.wixstatic.com/media/###~mv2.jpg",
"height": 0,
"width": 0,
"filename": "###.jpg"
},
"tagIds": [],
"relatedPostIds": [],
"pricingPlanIds": [],
"language": "en",
"changeOrigin": "PUBLISH",
"contentId": "662a028ff14ba036630988ba",
"editingSessionId": "7ae2f474-01dd-4711-91b3-66483e4f760a",
"status": "PUBLISHED",
"mostRecentContributorId": "a7083f9c-f008-425b-8880-6f3f8362b38d",
"hasUnpublishedChanges": false,
"editedDate": "2024-04-25T07:34:09.626Z",
"firstPublishedDate": "2024-04-25T07:00:11.188Z",
"seoData": {
"tags": [],
"settings": {
"preventAutoRedirect": false,
"keywords": []
}
},
"slugs": [
"###"
],
"createdDate": "2024-04-25T07:00:10.752Z",
"seoSlug": "###",
"media": {
"wixMedia": {
"image": {
"id": "###~mv2.jpg",
"url": "https://static.wixstatic.com/media/###~mv2.jpg",
"height": 0,
"width": 0,
"filename": "###.jpg"
}
},
"displayed": true,
"custom": false
},
"translations": []
}
}
Neverthe less the OG image works well.
I kindly thank you for your help and if you need further information, please let me know.
PS: Here are my data send to the API create draft post (I have removed richContent
to avoid having it too long…
Summary
{
"draftPost": {
"richContent": {},
"title": "###",
"heroImage": {
"id": "###~mv2.jpg"
},
"media": {
"displayed": true,
"wixMedia": {
"image": {
"id": "###~mv2.jpg"
}
}
}
},
"action": "UPDATE_PUBLISH"
}