Get Image ContentLink

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

Get Image ContentLink

All Replies

Posted by Community Admin on 05-Jun-2015 00:00

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();

Posted by Community Admin on 10-Jun-2015 00:00

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

 
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 11-Jun-2015 00:00

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();​​

This thread is closed