Module Builder and Images

Posted by Community Admin on 04-Aug-2018 22:38

Module Builder and Images

All Replies

Posted by Community Admin on 04-Apr-2012 00:00

I have a custom module that has a couple of image fields in it.  I'm able to get the images perfectly fine from a code behind, but it's another story when I'm trying to do it in  a widget template.

Is there an easy way to use images in a widget template?  Should I be using one of your controls to do the job?

This is all I was able to figure out; it isn't pretty, and it actually only gives me the .tmb file.

            <img alt='<%# Eval("Title")%>' src='<%# ((Telerik.Sitefinity.Model.ContentLinks.ContentLink[])Eval("MainImage")).LastOrDefault().ChildItemAdditionalInfo %>' />


Posted by Community Admin on 05-Apr-2012 00:00

Hi Patrick,

I believe the field you are looking for is "AssetsField". Here is an example from the Showcases module demo:

<sf:AssetsField ID="AssetsField1" runat="server" DataFieldName="Screenshot" Width="205" />

Where "Screenshot" is the name of the media field for the custom module. For more info I encourage you to check out the blog post and video: Building real-world modules with Sitefinity’s new Module Builder

If you're wanting to have more control over it by getting the exact url link, take a look at this follow up blog post: Retrieving Data From Dynamic Modules Using the Module Builder API

specifically the section "Binding to fields" where a Helper Method is used to parse out the ContentLink from the API.

I hope this is helpful!

Posted by Community Admin on 05-Apr-2012 00:00

Thanks, I knew there had to be a sf control that would do the trick.

Posted by Community Admin on 22-May-2012 00:00

Hi SelAromDotNet,

I need to add a title attribute in the img tag for my jQuery. 
<img ... title="some text" .../>
I understand that sf:AssetsField will create an img tag.  So I added the title attribute into an AssetsField,
<sf:AssetsField ... title="some text" .../>
but the generated img tag doesn't contain the title attribute. I am using Module Builder and don't have code behind. Is there any way around?

Posted by Community Admin on 29-Aug-2012 00:00

I'm trying to specify some static text in my hyperlink when using the document selector as a field. Anyone been able to do it? This does not work: <sf:AssetsField runat="server" DataFieldName="BusinessCard" Text="vCard" /> 

Posted by Community Admin on 29-Apr-2014 00:00

2 years on I'm hoping there's a solution to getting just the Image URL. I don't want all the extra divs the AssetsField wraps the image in. I only want the image. Thats it. I just want it to say 

<img src="locationOfMyImage.jpg" />
 or even better would be just the URL to the image -- instead of

<div>
  <div class="sfimageWrp">
     <img src="locationOfMyImage.jpg" />
  </div>
</div>
 

Does anyone know how to do this?

This thread is closed