I found this great bit of code that works very well thanks to:
http://www.sant-media.co.uk/2010/07/how-to-use-prettyphoto-in-wordpress-galleries/
add_filter( 'wp_get_attachment_link', 'lod_prettyPhoto');
function lod_prettyPhoto ($content) {
$content = preg_replace("/<a/","<a rel=\"prettyPhoto[gallery1]\"",$content,1);
return $content;
}
I want to use the native WordPress gallery and use prettyPhoto as jquery lightbox, so far so good.
I am learning PHP and I believe what I am doing above is finding and replacing the link tag and replacing it with a link tag and the rel = "prettyPhoto[gallery1]"
But I want the rel tag to be generated by the alt field that the client can complete and in that way have multiple prettyPhoto galleries (and not just one photo gallery called "gallery1").
So I tried reworking the code ( pasted below ), creating a variable for the alt tag, and then using this variable inside the rel tag of my code, but on the line where I created the variable I get a PHP error:
syntax error, unexpected '(', expecting T_VARIABLE or '$' in ...
and a Google search hasn't helped me figure out what I'm doing wrong either.
Any help would be greatly appreciated! _Cindy
My new code with dynamically generated rel tags:
add_filter( 'wp_get_attachment_link', 'lod_prettyPhoto');
function lod_prettyPhoto ($content) {
$relAlt = $(this).closest("img").attr("alt");
$content = preg_replace("/<a/","<a rel=\"prettyPhoto[$relAlt]\"",$content,1);
return $content;
}