Is there any way to take a base 64 string, for example:
.copyIcon {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAW0lEQVR42mNgQALCi7//J4QZcAFiNOM1hJANBA0h1QC83iHFizDJ/dgww/7/LAQNwKUZbkjDfya8YQZXiCqJagilBmAzhLYGYDNsJBhAMD3gS854NS/6vg+fZgDKvmW19S7PRAAAAABJRU5ErkJggg==") center center no-repeat;}
And replace a solid color with another solid color using JavaScript?
In this specific example I have a solid color in the icon (#13A3F7) that I would like to replace with another solid color (#ff6400).
The reason for doing this is it is not a one-off. I would like to be able to change the icon to any color with a setting.
Is there any way I can do this?
Here is a little function which takes 3 parameters: data, colorFrom, colorTo (both colors should be supplied in hex)
An additional function is required to convert hex colors to RGB (for correct matching)
Usage would be like so:
It will return a new data:image/png; URI with the swapped colors, here is a working jsfiddle of the end result
http://jsfiddle.net/V5dU2/
(tested on Chrome, Firefox and IE10)