display custom image field in custom template

Posted by Community Admin on 03-Aug-2018 18:48

display custom image field in custom template

All Replies

Posted by Community Admin on 23-Apr-2015 00:00

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?

Posted by Community Admin on 23-Apr-2015 00:00

Tim,

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

www.youtube.com/watch

 

Craig

Posted by Community Admin on 23-Apr-2015 00:00

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?

Posted by Community Admin on 23-Apr-2015 00:00

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

Posted by Community Admin on 28-Apr-2015 00:00

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
 

Posted by Community Admin on 28-Apr-2015 00:00

Sabrie,

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

Posted by Community Admin on 23-Sep-2015 00:00

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.

Posted by Community Admin on 23-Sep-2015 00:00

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. 

Posted by Community Admin on 02-Oct-2015 00:00

Thanks

Posted by Community Admin on 09-Feb-2017 00:00

Sabrie this solution worked fine but it's targeting the largest image, is there a call for one of the other sizes?

 

Charles

This thread is closed