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

Forums / Developing with Sitefinity / Module Builder and Images

Module Builder and Images

6 posts, 1 answered
  1. Bernstein-Rein
    Bernstein-Rein avatar
    30 posts
    Registered:
    12 Mar 2010
    04 Apr 2012
    Link to this post
    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 %>' />

  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    05 Apr 2012
    Link to this post
    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!
    Answered
  3. Bernstein-Rein
    Bernstein-Rein avatar
    30 posts
    Registered:
    12 Mar 2010
    05 Apr 2012
    Link to this post
    Thanks, I knew there had to be a sf control that would do the trick.
  4. Jimmy
    Jimmy avatar
    7 posts
    Registered:
    23 Apr 2012
    22 May 2012
    Link to this post
    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?
  5. Ben
    Ben avatar
    44 posts
    Registered:
    27 Sep 2012
    29 Aug 2012
    Link to this post
    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" /> 
  6. Richard
    Richard avatar
    64 posts
    Registered:
    09 Oct 2012
    29 Apr 2014 in reply to Ben
    Link to this post

    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?

6 posts, 1 answered