sf:ImageField doesn't display the image
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" />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>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?
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; 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