Enabling Pretty Photo Integration for all Single Images
Hello.
I LOVE what you guys did with this theme. Beautiful work.
I do however have a problem that I'm hoping you can help me with. I'm using the built-in PrettyPhoto integration. ANd I love it! It works flawless out-of-the-box on Galleries. However it doesn't seem to work at all on single images. I know that we need to add the rel="prettyphoto" tag to the single images. I just imported over 200 posts with images. Adding over 200 rel tags will take forever. So there has to be an easier way. Plus I'm thinking that since you found a way to automatically enable prettyPhoto integration for all Galleries, there has to be a way to do the for single images as well. How can we get this enabled? Is there a line of code I can change in the theme files to make PrettyPhotos work on all single images in posts?
I tried to force it using Javascript, so I added the following code to BeTheme Options –> Custom JS:
jQuery(document).ready(function(){
jQuery('.post-wrapper-content a').has('img').attr('rel', 'prettyphoto');
});
It adds the rel="prettyphoto" tag to the links. However even with that added, the images still don't open in the PrettyPhoto lightbox. Instead they still open the link to the original file.
Suggestions?
Thank you!
David
I LOVE what you guys did with this theme. Beautiful work.
I do however have a problem that I'm hoping you can help me with. I'm using the built-in PrettyPhoto integration. ANd I love it! It works flawless out-of-the-box on Galleries. However it doesn't seem to work at all on single images. I know that we need to add the rel="prettyphoto" tag to the single images. I just imported over 200 posts with images. Adding over 200 rel tags will take forever. So there has to be an easier way. Plus I'm thinking that since you found a way to automatically enable prettyPhoto integration for all Galleries, there has to be a way to do the for single images as well. How can we get this enabled? Is there a line of code I can change in the theme files to make PrettyPhotos work on all single images in posts?
I tried to force it using Javascript, so I added the following code to BeTheme Options –> Custom JS:
jQuery(document).ready(function(){
jQuery('.post-wrapper-content a').has('img').attr('rel', 'prettyphoto');
});
It adds the rel="prettyphoto" tag to the links. However even with that added, the images still don't open in the PrettyPhoto lightbox. Instead they still open the link to the original file.
Suggestions?
Thank you!
David
Comments
we are very sorry but what you ask for, requires files customization what in reference to Item Support Policy is not allowed. So if you want to modify files and don't know how, you should contact with your web developer.
Thanks for understanding!
_________
add_filter('the_content', 'my_addlightboxrel');
function my_addlightboxrel($content) {
global $post;
$pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$replacement = '<a$1href=$2$3.$4$5 rel="prettyphoto" $6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
_________
It gets the job done in the way I needed - it adds the "prettyphoto" rel tag to single photo links. Hope this helps someone in the future.