Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. ImageFieldValue imageUrl = oListItem["PublishingRollupImage"] as ImageFieldValue;
  2. if (imageUrl != null)
  3. {
  4. item.imageUrl = imageUrl.ImageUrl;
  5. item.imageWidth = imageUrl.Width.ToString();
  6. item.imageHeight = imageUrl.Height.ToString();
  7. }
  8.  
  9. ListItem targetListItem = list.GetItemById(8);
  10.  
  11. context.Load(targetListItem, item => item["PublishingRollupImage"]);
  12. context.ExecuteQuery();
  13.  
  14. //give value containing img tag
  15. var imageField = Convert.ToString(targetListItem["PublishingRollupImage"]);
  16.  
  17. //Regex to extract the src value from the img tag
  18. string imageUrl = Regex.Match(imageField, "<img.+?src=["'](.+?)["'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement