sf:ImageField doesn't display the image

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

sf:ImageField doesn't display the image

All Replies

Posted by Community Admin on 10-Jul-2013 00:00

I created a custom module using Module builder.
There is an image field "Thumbnail", I like to display in the list view. Since it is an optional field, and in case of its absence, I need to display a default image.

When I use ImageField with DefaultSrc pointing to the default image, only image I see in the list view is the default image. Even the content with thumbnail field populated, displays the default image instead:

<sf:ImageField runat="server"
  DataFieldName="Thumbnail"
  DataFieldType="Telerik.Sitefinity.Model.ContentLinks.ContentLink"
  DisplayMode="Read"
  DefaultSrc="~/images/default-source/grants/thumbnails/default.png" />


What am I missing here? Does "DefaultSrc" attribute have a different purpose or use case than I am trying to accomplish?

Thanks,

Osman

Posted by Community Admin on 11-Jul-2013 00:00

Not sure what the DefaultSrc should be doing but maybe trying this sf:conditional statement.  This is from the forum list but you can change the parameters to fit your needs.

<sf:Conditional If='<%# (DateTime)Eval("UserRegistrationDate") > DateTime.MinValue.ToUniversalTime() %>' runat="server">
                   <Then>
                       <div class="sfforumUserPostsInfo">
                           <%# Eval("UserPostCount") %> <asp:Literal Text="<%$ Resources:ForumsResources, Posts %>" runat="server" /><br />
                    
                           <asp:Literal Text="<%$ Resources:ForumsResources, RegisteredTitleCase %>" runat="server" />:<br />
                           <%# ((DateTime)Eval("UserRegistrationDate")).ToString("dd MMM yyyy") %>
                       </div>
                   </Then>
               </sf:Conditional>

Posted by Community Admin on 12-Jul-2013 00:00

Thanks Jonathan for your suggestion.
I didn't know about sf:Conditional, which will be very handy for sure.

I still would like to know how sf:ImageField's DefaultSrc suppose to work though. Anyone?

Posted by Community Admin on 15-Jul-2013 00:00

Hi guys,

 In the js file of the ImageField we make the following check:

if (this._imageElement.src == "")
    if (this._defaultSrc)
        this._imageElement.src = this._defaultSrc;
    
In such case, the defaultSrc should only get applied when the ImageElement doesn't have a src value.

Regards,
Jen Peleva
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 15-Jul-2013 00:00

Hi Jen,

I am not really clear this check is only done in client-side JavaScript.

With this control, my assumption was the default image would be displayed if Thumbnail image is not defined.
However, if I use the <sf:ImageField component as described above; in a user control/widget, I only see the default image, even when Thumbnail is defined.

So Jen, I appreciate if you could clarify the usage scenarios of <sf:ImageField /> and the DefaultSrc attribute.

Thanks,
Osman 

This thread is closed