3

In my web app, I need to desaturate/grayscale some pictures. I am using the following CSS to achieve that:

.grayscale {
  filter: grayscale(100%); /* Current draft standard */
  -webkit-filter: grayscale(100%); /* New WebKit */
  -moz-filter: grayscale(100%);
  -ms-filter: grayscale(100%);
  -o-filter: grayscale(100%); /* Not yet supported in Gecko, Opera or IE */
  filter: gray; /* IE6-9 */
  -webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
  filter: url("data:image/svg+xml;utf8,<svg%20xmlns='http://www.w3.org/2000/svg'><filter%20id='grayscale'><feColorMatrix%20type='matrix'%20values='0.3333%200.3333%200.3333%200%200%200.3333%200.3333%200.3333%200%200%200.3333%200.3333%200.3333%200%200%200%200%200%201%200'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
  -webkit-filter: grayscale(1); /* Old WebKit */
}

This covers a wide array of browser. The problem is that some older ones like Safari 5 are not affected by it. I know there are some jQuery libraries like Pixastic that do support those older browsers but I would like to use as less jQuery as possible to make my page load as fast as possible. Therefore, my question is: it possible to check if the image was grayscaled and if not, use a jQuery plugin like Pixastic to do so?

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
amb110395
  • 1,545
  • 13
  • 16
  • possible duplicate of [modernizr check for grayscale filters IE 10](http://stackoverflow.com/questions/16150423/modernizr-check-for-grayscale-filters-ie-10) -- different question, but the same solution. – Brigand Aug 05 '13 at 01:09

1 Answers1

2

you can use modernizr to detect css filters: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css/filters.js

Matej Chrenko
  • 188
  • 11