Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created August 13, 2013 19:32
Show Gist options
  • Save WebEndevSnippets/6224805 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/6224805 to your computer and use it in GitHub Desktop.
Plugin: Add rel="prettyPhoto" attribute automatically as image is inserted into post
add_filter( 'image_send_to_editor', 'we_insert_img_rel_attrib', 10, 6 );
/**
* Add rel="prettyPhoto" attribute automatically as image is inserted into post
* Requires PrettyPhoto JS enqueue
*/
function we_insert_img_rel_attrib( $html, $id, $caption, $title, $align, $url ) {
$rel = "<a rel=prettyPhoto";
if ($url) {$html = str_replace("<a",$rel,$html);}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment