Advertisement
miriamdepaula

WordPress: Adicionando rel=lightbox em todas as imgs do post

Aug 26th, 2011
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. /*
  2. Adicionando rel="lightbox" em todas as imagens do post automaticamente. Lembre-se de instalar o jquery lightbox (do Leandro Vieira - http://leandrovieira.com/projects/jquery/lightbox/).
  3. */
  4.  
  5. function add_lightbox_rel($content) {
  6. $pattern = '/<a(.*?)href="(.*?).(bmp|gif|jpeg|jpg|png)"(.*?)>/i';
  7. $replacement = '<a$1href="$2.$3" rel=\'lightbox\'$4>';
  8. $content = preg_replace( $pattern, $replacement, $content );
  9. return $content;
  10. }
  11. add_filter( 'the_content', 'add_lightbox_rel' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement