1

Is there any way to get site logo url in Sharepoint Online App (CSOM) ? I can't find any solution.

var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var context = new SP.ClientContext.get_current();
var hostcontext = new SP.AppContextSite(context, hostUrl);
var web = hostcontext.get_web();
var logo = context.siteLogoUrl;

logo returning undefined. Can someone help me ?

  • you can directly get it from _spPageContextInfo.webLogoUrl – Sunil Sahu Nov 7 '16 at 15:30
4

Site logo url is exposed using the method get_siteLogoUrl().

Try the below code:

var hostUrl = GetUrlKeyValue("SPHostUrl");
var context = new SP.ClientContext.get_current();
var hostcontext = new SP.AppContextSite(context, hostUrl);
var web = hostcontext.get_web();
context.load(web);
context.executeQueryAsync(function () {
          var logo= web.get_siteLogoUrl();
        },
                function (sender, args) {
                    console.log(args.get_message());
                });
  • I tried your solution but it was not worked. And tried some other solutions but still not achieve to work. – Yasin Yörük Nov 9 '16 at 20:23
  • What is the error you are getting? – Unnie Nov 9 '16 at 20:25
  • I'm getting undefined output. I read; "Site logo url is not reachable in CSOM". at the MSDN. So I pause to search solution for this problem. – Yasin Yörük Nov 9 '16 at 20:57
  • Make sure that you have uploaded a custom logo to the host web. Sitelogourl is accessible using CSOM.The above code is tested in my app – Unnie Nov 9 '16 at 20:59
  • Ok, I'll try to upload custom logo. I'll write result. – Yasin Yörük Nov 9 '16 at 21:11
0

You can get it from _spPageContextInfo. No request is needed to the server using context.executeQueryAsync(). Just use following!!

var logo = _spPageContextInfo.webLogoUrl;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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