0

I have set one image as a background image in SharePoint Master page.

So here issue I am facing is in displaying this image in my non-root site collection.This works perfectly in my root site collection.

I am using a relative path to the library to display image ex. /Images/coffeebean.jpg.

By using developer tools I came to know that hovering on that relative path image it shows the path from the root site collection.

http://SITECOLLECTION/Images/coffeebean.jpg

instead of

http://SITECOLLECTION/sites/test/Images/coffeebean.jpg

I don't want to use absolute URL.

Any help will be appreciated!!

1 Answer 1

0

There are 2 ways you can insert an image in a SharePoint master page. Both of them are relative url.

14 Hive (Physically hosted): You can place your images physically in the 14 hive folder under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES

Place a image here (logo.png) and you can access this image in your masterpage like this

<SharePoint:SiteLogoImage LogoImageUrl="/_layouts/images/logo.png" runat="server"/>

Site Collection (Library hosted) Upload the logo.png file in any document library on your site collection. If your library name is "Images" here is how you can access the image.

<img src="../../Images/logo.png" />

Both the approaches are fine depending on your portability requirement of the site.

Check the below MSDN links for reference

Understanding Absolute and Relative URL Addresses

Good practice for image URLs

MSDN Forum link Adding relative image in master page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.