2

I like reusing OOB SharePoint icons in my custom apps. I usually just copy the img URL into one of my tags but it seems with themes, they have a themedpng extension. How can I reuse the 'New Item' plus Icon and have the same URI without breaking when going to another environment?

enter image description here

It shows this Img src in the markup:

/sites/_catalogs/theme/Themed/B5CDC77D/spcommon-B35BB0A9.themedpng?ctag=2
2
  • It seems that you are using themed glyph icons as your custom image source. It will not be found on another environment as there will be different theme code in that. Would prefer not to use this way. Instead you can use custom image source as in SharePoint OOB.
    – Pradip R.
    May 26, 2015 at 19:45
  • If I do that, wouldn't it be the OOB SharePoint blue instead of matching our Theme? I think I could probably just crop the button and deploy it as an image with the solution. I was hoping there would be a way to generate the dynamic theme code using tokens or something May 26, 2015 at 20:17

1 Answer 1

1

It is possible to do this. If you are deploying ASPX pages in your app you can use the ThemeControl

<SharePoint:ThemedForegroundImage ThemeKey="spcommon" ImageUrl="/_layouts/15/images/spcommon.png" runat="server" CssClass="myclass" ID="myElementId" />

MSDN: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.themedforegroundimage.aspx?f=255&MSPPError=-2147217396

There is also a GetThemedImageUrl method in the SharePoint Utility class which will return the encoded URL path to your image.

MSDN: https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.utilities.sputility.getthemedimageurl.aspx

Your Answer

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

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