Friday, 18 September 2015

Custom Ribbon Action and Set the Customize Icon to Ribbon Button in a SharePoint Hosted App

Introduction 
In this article you will learn how to set the Customize Icon to Ribbon Button in a SharePoint Hosted App.

This article explains the Custom Ribbon Action to set the Custom Image to a Ribbon button and that is absolutely awesome! I was creating a Custom Action in my SharePoint Hosted app. I wanted to add a Button into the Ribbon of any Custom List to my App Web and do some work based on List Information. I started by adding a Custom Ribbon Action.

Custom Ribbon button

create Custom action for Ribbon

ribbon listItem

You can see the following code snippet of elements.xml of the Custom Ribbon Action that will be generated for you based on your settings selected in the wizard.

selected in the wizard

Have a look at the highlighted code in the previous block. You will notice that the icon of the button is a placeholder you have the ability to change. The next screenshot shows the button with the placeholder icon:

placeholder icon

Solution:
A better workaround is to use Data URIs that is a way of embedding the actual image data in the src attribute of the img tag. The only limitation is browser support for example.

The code after applying this workaround will be like this:

applying this workaround

The following is the final output of the Customize Icon to Ribbon button.

Ribbon button

Note: There are many image data URI generators online like this one.

No comments:

Post a Comment

SharePoint 2013 - Uploading Multiple Attachments To The New Item On List Using JSOM And REST API

  Introduction In this article, we will explore how we can attach multiple attachments to the new item on list using JSOM and REST API. Ther...