Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save post with featureImage not working #88

Open
alikianinejad opened this issue Jul 17, 2018 · 2 comments
Open

save post with featureImage not working #88

alikianinejad opened this issue Jul 17, 2018 · 2 comments

Comments

@alikianinejad
Copy link

alikianinejad commented Jul 17, 2018

i am trying to save new post with thumbnail in wordpress database with following code

        var img_url = SourceURL.Text + "/files/images/thumb/400_" + data.my_post.thumbnail;
        var featureImage = Data.CreateFromUrl(img_url);
        var img = data.client.UploadFile(featureImage);

        post.FeaturedImageId = img.Id;
        post.Id = data.client.NewPost(post);

and after that with checking database i see the new post and attachment and file upload successfully in wp-content/uploads but in attachment record parent_post set to 0 instead of new post id and thumbnail field is empty in wordpress how can i fix that i check blow links
How to add thumbnail image into newPost #44
Featured Images & Custom Fields #64

@Blackcat156
Copy link

Please use the same post send request to complete the upload process。
For example CreateFromUrl(Post post,stirng ImgUrl)

@Blackcat156
Copy link

I have the same problem with you today. The solution is as follows:
UploadResult img = client.UploadFile(WordPressSharp.Models.Data.CreateFromUrl(item, "image/jpeg"));
If no file type is set,The default file type is: application/octet-stream
It can't be set as a cover picture.
So set the parameter: image/jpeg
You can solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants