Reputation: 1545
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?
Upvotes: 3
Views: 224
Reputation: 188
you can use modernizr to detect css filters: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css/filters.js
Upvotes: 2