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?

1

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. The few tests I made show that Modernizr is working

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.