Thumbnail url of the news item
Hi All,
I am having a newsitem object and i need to get the url of the thumbnail image of that particular news item. Here is the code i am using:
public string GetNewsImage(NewsItem item)
string imageUrl = string.Empty;
if (item != null)
var relatedItems = item.GetRelatedItems("Thumbnail");
var thumbNail = relatedItems.FirstOrDefault();
if (thumbNail != null)
LibrariesManager lb = new LibrariesManager();
try
var image = lb.GetImage(thumbNail.Id);
if (null != image)
imageUrl = image.ItemDefaultUrl;
catch(Exception ex)
return imageUrl;
But i am not getting all the images with the correct path. Some of the images are not getting the right path using this method. What am i doing wrong. PAny help or hint.
Thanks in advance!!
Anju Raman
Hello Anju,
Can you please tell me whether you are using related media field in the news module of your project? If this is correct you can check the following documentation article:
Query item relations using ContentLinksManager
Regards,
Kaloyan
Telerik