Set image of ImageControl with Native API

Posted by Community Admin on 04-Aug-2018 11:12

Set image of ImageControl with Native API

All Replies

Posted by Community Admin on 20-Nov-2014 00:00

 Hello,

 I'm trying to insert an ImageControl into a page, I have it partially done. I get the control on the page
but I can't set an image. I get the message: "An image was not selected or has been deleted. Please select another one." I tried it with image.Id and image.FileId but both not working. I searched in the
object for the same GUID as I see in the backend but I can't find that. So, how do I select an image?

ImageControl imageBlock = new ImageControl();
imageBlock.ImageId = imageBlock.Manager.GetImages().FirstOrDefault().FileId;
PageDraftControl imageBlockDraftControl = manager.CreateControl<PageDraftControl>(imageBlock, "Body");
imageBlockDraftControl.ObjectType = "Telerik.Sitefinity.Web.UI.PublicControls.ImageControl, Telerik.Sitefinity";
imageBlockDraftControl.Caption = "Image";

Posted by Community Admin on 25-Nov-2014 00:00

Hi Jens,

Notice that the ImageId of the control needs to be the Id of the image in Live version instead of the FileId. For instance:

imageBlock.ImageId = imageBlock.Manager.GetImages().Where(i=>i.Title=="The image title" && i.Status== Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible==true).Single().Id;


Best Regards,
Junior Dominguez
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 25-Nov-2014 00:00

Hi Junior Domingues,

Thanks for your reaction.
As I mentioned in my description I tried it with Id and FileId, both didn't work.
And because the Id field didn't work I started to try other fields like FileId.

 Greetings,
Jens

Posted by Community Admin on 27-Nov-2014 00:00

Hi Jens,

Running a local test I was able to set the ImageControl using the API and using the image Id and the code snippet provided before as shown in this short video.


Best Regards,
Junior Dominguez
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed