Try Now
More in this section

Forums / Developing with Sitefinity / Image.Id or Image.FileId

Image.Id or Image.FileId

2 posts, 0 answered
  1. Theodore
    Theodore avatar
    6 posts
    02 Mar 2012
    14 May 2014
    Link to this post

    can anyone tell me the difference between and image.id and image.FileId?   

    I'm getting all the images from an album and building a UL with links around the images to a different page trying to pass the imageid but they all seem to be the same.  FileId seems to be unique but I can't find what the difference is. 

    this is my code.

    var imagelist = (from t in GetImagesByAlbumNativeAPI(album.Id)
    orderby t.DateCreated descending
    select t).Take(3);
    htm = "<ul class=WorkAllUl>";
    string currenturl = "/work/" + LOBName.Replace(" ", "-");
    if (imagelist.Count() > 0)
    foreach (var m in imagelist)
    htm += "<li class=WorkAllLi>";
    htm += "<a href=" + currenturl + "?id=" + m.Id + "&id2=" + m.FileId + ">";
    htm += "<img src='" + m.Url + "' alt='" + m.AlternativeText + "' data-image-id='" + m.Id + "' data-image-Fileid='" + m.FileId + "' class=WorkAllImage></a>";
    htm += "</li>";

  2. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    26 Mar 2015
    15 May 2014
    Link to this post
    Hi Theodore,

    The ID you need is Image.Id. It relates to the image and represents it in the database. The FileId property is also related to the image, but is only used to generate thumbnails for the image. As far as the issue goes, I can only imagine there is something wrong with your initial query. All Image Ids are unique and represent an image. I can suggest the following lines that will return the ID of 3 published images:
    LibrariesManager librariesManager = LibrariesManager.GetManager();
               var AlbumId = librariesManager.GetAlbums().Where(a => a.Title == "YourAlbum").FirstOrDefault();
               var imagelist = AlbumId.Images().Where(i => i.Status == ContentLifecycleStatus.Live).Take(3);

    Ivan D. Dimitrov
    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
2 posts, 0 answered