Looking in the CMS, I can see it has successfully saved the node; the image is there and so is a cropped version. Great.
Problem is that the image src will not output on front end until I manually go the node and 'save and publish'. Src just appears empty until I do this.
1) Image is saved to node (image cropper field) via Content Service
2) I check content, image is present in node :-)
3) Image ought to show in view but it does not.
4) If I hit 'save and publish' in CMS , image now appears on view
So it's like I have to save it again to get it to work. How can I get it to work without step 4?
Ok. I finally figured it out with a different around the houses approach. It works, not sure if it's the right way though as a newbie...
1) Used Media Service to upload image via a Surface Controller
2) Used Content Service to create node
3) Store a date stamp in both the image and node
4) In partial view macro, iterate through folder and display the image that matches the magic date stamp.
Seems a bit long-winded - hopefully not too resource heavy. I did it this way because Media Service puts each image you upload in a separate folder, meaning you can't predict the path to file, even if you know the name.
Also, I also couldn't find a way to rename the file so I couldn't be certain it would be unique.
I'd imagined you would be able to save an image straight to a node, but seems not.
Any clarifications you can give to help me clean up my act would be appreciated.
Node creation with image cropper field
I'm successfully creating nodes through a surface controller.
Here's how I'm populating image cropper filed and saving a node...
contentNode.SetValue("image", @"\uploadedImages\Avatargirlface.png"); contentService.SaveAndPublish(contentNode);
Looking in the CMS, I can see it has successfully saved the node; the image is there and so is a cropped version. Great.
Problem is that the image src will not output on front end until I manually go the node and 'save and publish'. Src just appears empty until I do this.
I expected this to happen automatically.
Any ideas what I am missing please?
Just some more info in case this is not clear...
1) Image is saved to node (image cropper field) via Content Service 2) I check content, image is present in node :-) 3) Image ought to show in view but it does not. 4) If I hit 'save and publish' in CMS , image now appears on view
So it's like I have to save it again to get it to work. How can I get it to work without step 4?
Please help, I've spent ages on this. Thanks.
Hello.
Ok. I finally figured it out with a different around the houses approach. It works, not sure if it's the right way though as a newbie...
1) Used Media Service to upload image via a Surface Controller
2) Used Content Service to create node
3) Store a date stamp in both the image and node
4) In partial view macro, iterate through folder and display the image that matches the magic date stamp.
Seems a bit long-winded - hopefully not too resource heavy. I did it this way because Media Service puts each image you upload in a separate folder, meaning you can't predict the path to file, even if you know the name.
Also, I also couldn't find a way to rename the file so I couldn't be certain it would be unique.
I'd imagined you would be able to save an image straight to a node, but seems not.
Any clarifications you can give to help me clean up my act would be appreciated.
Cheers.
// My solution was the one above.
is working on a reply...