1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Image object questions

Image object questions

5 posts, 1 answered
  1. Ivan
    Ivan avatar
    51 posts
    Registered:
    22 Aug 2007
    07 Dec 2009
    Link to this post
    Hi,

    Is there a Telerik image object which exposes it properties such as name, alternate text, etc?  If not what is the expected way to get this information from the repository programmatically?  Is there also a way to add a description field to an image object?  I do not see a field for this information in the modules view.

    Thanks in advance.
    -Ivan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Dec 2009
    Link to this post
    Hi Ivan,

    You can use IContent objects from Images and Documents module that supports metakeys as name, description alt text. Another option is using SitefinityImage control that works with dynamic links.

    Let us know if there is anything else that we can do for you.


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Ivan
    Ivan avatar
    51 posts
    Registered:
    22 Aug 2007
    07 Dec 2009
    Link to this post
    Hi Ivan,

    I'm not quite clear on the approach you are describing.  Here is the code I have so far:

    1 Telerik.Libraries.ILibrary theLibrary = libraryManager.GetLibrary("Photos"); 
    2 foreach(CmsContentBase c in theLibrary.GetItems()) 
    3
    4      // How do I get name and alternate text for this image from this point? 
    5       
    6
    7  

    Is there an object that is more strongly typed than CmsContentBase that I can use to get the name and alternate text that I've entered in the Image & Documents module?  It seems I can parse the CmsContentBase.Url for the image name but not anything to get the alternate text which has to be stored somewhere.

    Any insight would be appreciated.  Thanks.
    -Ivan
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    08 Dec 2009
    Link to this post
    Hello Ivan,

    You can try the following:

    LibraryManager libraryManager = new LibraryManager();
    ILibrary library = libraryManager.GetLibrary("LibraryName");
    foreach (IContent content in library.GetItems())
    {
        if (content.MimeType == "image/jpeg")
        {
            string imageName = content.GetMetaData("Name").ToString();
            string imageAltText = content.GetMetaData("AlternateText").ToString();
        }
    }

    More samples on this can be found in our on-line developer manual, check this article in particular: Managing Files with LibraryManager


    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  5. Ivan
    Ivan avatar
    51 posts
    Registered:
    22 Aug 2007
    08 Dec 2009
    Link to this post
    Thanks Radoslav!  This is just what I needed.
Register for webinar
5 posts, 1 answered