Get Image ContentLink
I'm trying to upload an image to a Library, get a ContentLink for that image and add this to the Dynamic Module I've created. But I'm not sure how to get the ContentLink during creation of the image? My code looks like, but GetContentLink expect parameters, but I just want to get the ContentLink for the item I am uploading?
// upload image to the album
fluent
.Album(album.Id)
.CreateImage()
.Do(item =>
item.Title = (string)(SiteProperty.GetValue("DisplayAddress") + " "+name);
imageID = item.Id;
SiteProperty.SetValue("Images",(ContentLink)item.GetContentLink());
)
.CheckOut()
.UploadContent(stream, ".jpg")
.CheckIn()
.Publish()
.SaveChanges();
Hello David,
In order to add image to a DynamicContent Item you can check the code provided in that discussion.
You can also take a look on that article:
- Add related media custom field to content items
Regards,
Svetoslav Manchev
Telerik
Thanks Svetoslav,
I'd missed a reference:
using Telerik.Sitefinity.RelatedData;
And then as per the post creating the link:
SiteProperty.CreateRelation(item, "Images");
So upload now looks like:
// upload image to the album
fluent
.Album(album.Id)
.CreateImage()
.Do(item =>
item.Title = (string)(SiteProperty.GetValue("DisplayAddress") + " "+name);
imageID = item.Id;
SiteProperty.CreateRelation(item, "Images"); //Add ContentLink to dynamic module
)
.CheckOut()
.UploadContent(stream, ".jpg")
.CheckIn()
.Publish()
.SaveChanges();