Advertisement
Guest User

grayscale images

a guest
Sep 13th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. first the java...*this could be done far easier with Jquery*... just couldnt get the library when i was working on this..*
  2.  
  3. you'll need to put a copy of filters.svg on your site somewhere...
  4. open a text file ...paste this...
  5.  
  6. `<svg xmlns="http://www.w3.org/2000/svg">
  7. <filter id="grayscale">
  8. <feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"/>
  9. </filter>
  10. </svg>`
  11.  
  12. save as filters.svg...FTP file to your site...remember the complete url.
  13.  
  14. 1st go to loop-slider.php
  15.  
  16. look for `return DO_NOTHING; }}`... paste next bit immediately after.
  17.  
  18. '<script type="text/javascript">
  19. function changebg<?php the_ID(); ?>(){
  20. var x="<?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'slider-thumb' ); ?>"
  21. document.getElementById('post-<?php the_ID(); ?>').style.cssText="background-image:url(<?php echo $thumbnail[0]; ?>); -webkit-filter: grayscale(1%); -moz-filter: grayscale(1%);";
  22. }
  23.  
  24. function changebgback<?php the_ID(); ?>(){
  25. var x="<?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'slider-thumb' ); ?>"
  26. document.getElementById('post-<?php the_ID(); ?>').style.cssText="background-image:url(<?php echo $thumbnail[0]; ?>); filter: url(http://yellowrootllc.com/site2/filters.svg#grayscale); filter: gray;-webkit-filter:grayscale(100%);-moz-filter: grayscale(100%);";
  27. }
  28.  
  29. </script>`
  30.  
  31. look for `<div id="post-<?php the_ID(); ?>`
  32.  
  33. replace entire paragraph with
  34. `<div id="post-<?php the_ID(); ?>" <?php post_class(); ?><?php if( isset( $thumbnail ) ) : ?> onmouseover="changebg<?php the_ID(); ?>();" onmouseout="changebgback<?php the_ID(); ?>()" style="background-image:url(<?php echo $thumbnail[0];?>); filter: url(http://yellowrootllc.com/site2/filters.svg#grayscale);-webkit-filter:grayscale(100%); filter: gray;-moz-filter: grayscale(100%);"<?php endif; ?>>`
  35.  
  36. change url to your svg file url, make sure to keep the "#grayscael" at the end of the url ...
  37.  
  38. im pretty sure thats it... i have about 7 changes still in there that i have commented out, but left in... so just make sure to save your loop-slider.php file first...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement