Solution: How to insert images into SiteFinity using ASP.NET

Posted by Community Admin on 03-Aug-2018 20:41

Solution: How to insert images into SiteFinity using ASP.NET or HTML image tags

All Replies

Posted by Community Admin on 26-Jan-2012 00:00

By Default SiteFinity does not allow you to use images using HTML or ASP.NET IMAGE TAGS:

Solution: 
we use \App_Themes\Images
we use the CSS \App_Themes\OurCompanNameTemplate.css

What did not work:
\images\imagename.png

What did work:
<img src="../../App_Themes/Images/icon_CourseCategoryHeading.PNG" border=0 vspace=0>

Thanks,
Doug Lubey of Louisiana


Search engine tags:
img tag src
<img src source
img tag src image folder
<asp:image
ASP.NET MASTER PAGES

Posted by Community Admin on 31-Jan-2012 00:00

Hi Doug,

Could you please give us some more details about your issue? Where do you enter the image - in a content block inside a page or as ASP.NET markup in a .master page? You can't enter ASP.NET tags in a content block but you can use the insert image dialog that is part of the rich Html field used to edit the content block contents.

Regards,
Lubomir Velkov
the Telerik team
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 31-Jan-2012 00:00

The problem occured.

Using imag tags (html or asp.net image tags) nside of a control.  The control is ultimately used inisde of a virtual page inside site finity.

yes: Hard coding the URL (inlcuding the http; etc)
....worked fine.

But I was looking for relativity....


Posted by Community Admin on 31-Jan-2012 00:00

Hi Doug,
I believe what you've encountered is a "bug" that was introduced with Sitefinity 4 (Telerik will tell you it's a feature). The issue is that the images module uses the /images/ name it the path and as you've noticed in another post the SF URL rewriting is very intrusive and prevents you from using the /images/ folder yourself. There is a way to change the image module to use something different i.e. "/imagelib/" but if you've already got images uploaded it's a pain and you'd have to worry about compatibility with upgrades etc. The easiest solution is to change your current /images/ folder to something like /img/ and then your images should display just fine.

Hope I understood your issue and that helps out. Also, I'm sure it's just a typo but in your example of "solution" and what "did not work" you're using backslashes instead of forward slashes.

Cheers,
Phill

Posted by Community Admin on 31-Jan-2012 00:00

That would be correct; I will mark your answer as correct;

here is an example which works too:

<asp:Image ID="Image2" runat="server" ImageUrl="~/ImagesDoug/slide4.png" />


Posted by Community Admin on 01-Feb-2012 00:00

This has been brought up quite a few times but I, still, really have to disagree that the way Sitefinity handles images is inconvenient. The website templates file structure shows how custom templates and themes should be constructed. If we follow it, the end result is a very organized and portable package.

To access files inside of your theme, you can use something like this:
/Sitefinity/WebsiteTemplates/AwesomeTemplateName/App_Themes/AwesomeThemeName/Images/logo.png

If an "Images" folder is required, because of existing code, then this knowledge base article covers how to change the default behavior.

My point is, like I said a moment ago, the recommended structure hasn't ever caused me an issue. It's really the way to go. :)

This thread is closed