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

Forums / General Discussions / display custom image field in custom template

display custom image field in custom template

9 posts, 1 answered
  1. Tim
    Tim avatar
    13 posts
    Registered:
    19 Nov 2012
    23 Apr 2015
    Link to this post

    I am finding that nothing is straightforward in Sitefinity and that finding documentation that addresses issues I encounter is difficult.  

     I created a custom field for News items that is an Image type.  I have also created a custom template for displaying the news items.  However, as part of that template, I want to display the image.  How does one accomplish this?

    Answered
  2. Craig
    Craig avatar
    45 posts
    Registered:
    28 Sep 2008
    23 Apr 2015 in reply to Tim
    Link to this post

    Tim,

    See if this helps...  Its a video from YouTube.

    https://www.youtube.com/watch?v=ZDsv6hQOw20

     

    Craig

  3. Tim
    Tim avatar
    13 posts
    Registered:
    19 Nov 2012
    23 Apr 2015 in reply to Craig
    Link to this post

    Craig,

     It seems I needed to include more info in my original post.  I am doing pure MVC pages.  My template was defined in Visual Studio.  If I display "item.Fields.NewsItemImage" in my template, "Telerik.Sitefinity.Frontend.Mvc.Models.ItemViewModel[]" is displayed on screen.  I simply do not know how to get from "Telerik.Sitefinity.Frontend.Mvc.Models.ItemViewModel[] " to being able to populate the src member of an img element.

    Any ideas?

  4. Craig
    Craig avatar
    45 posts
    Registered:
    28 Sep 2008
    23 Apr 2015 in reply to Tim
    Link to this post

    Tim,

    Sorry I don't have much knowledge in the Sitefinity MVC realm.  Definitely an area where I plan to learn more about in the future.  Good luck.  :-)

     

    Craig

  5. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    09 Dec 2016
    28 Apr 2015
    Link to this post
    Hi Tim,

    Can you please try to use the following sample code for displaying the custom related image of news items in an MVC widget template:


    @foreach (var relatedItem in item.Fields.RelatedImagesFieldName)
    {
      <img src="@relatedItem.Fields.MediaUrl" alt="@relatedItem.Fields.Title" />
    }

    Please note to replace the RelatedImagesFieldName with the name of your custom related field.

    You may also refer to the following documentation article for more details on this:
    https://github.com/Sitefinity/feather/wiki/Add-related-data-to-News-widget

    Regards,
    Sabrie Nedzhip
    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
     
  6. Tim
    Tim avatar
    13 posts
    Registered:
    19 Nov 2012
    28 Apr 2015 in reply to Sabrie Nedzhip
    Link to this post

    Sabrie,

     Thank you for your reply.  I reached out to Mariush on Friday and he was able to point me to a solution yesterday.

  7. Bill
    Bill avatar
    5 posts
    Registered:
    13 Dec 2010
    23 Sep 2015 in reply to Tim
    Link to this post
    could you please relay that solution here? When I read your initial post I almost thought that I had typed it. I am experiencing the exact same issue. It would be greatly appreciated.
  8. Tim
    Tim avatar
    13 posts
    Registered:
    19 Nov 2012
    23 Sep 2015 in reply to Bill
    Link to this post
    I wish I could provide that to you.  I was evaluating Sitefinity for a project.  It ended up not being the product chosen.  I have since uninstalled Sitefinity from my PC.  Sorry I couldn't be more help. 
  9. Mitra
    Mitra avatar
    3 posts
    Registered:
    07 Mar 2013
    02 Oct 2015 in reply to Tim
    Link to this post
    Thanks
9 posts, 1 answered