I think you need to make this change in your attachment plugin if lightbox is not supported- Find output line of the image and add to the url: rel = “prettyPhoto”.
Thank you! But I’m looking for a way to apply link: data-rel=”prettyPhoto” target = “_ self” to all available bbpress images. It can be loaded in any way, it doesn’t matter.
Found the code
function add_image_responsive_class ($ content) {
global $ post;
$ pattern = "/ <img (. *?) class = \" (. *?) \ "(. *?)> / i";
$ replacement = '<img $ 1class = "$ 2 img-responsive" $ 3>';
$ content = preg_replace ($ pattern, $ replacement, $ content);
return $ content;
}
add_filter ('the_content', 'add_image_responsive_class');
but for wordpress. Will it work for bbpress?
probably filter on
add_filter ('bbp_get_reply_content', 'add_image_responsive_class');
add_filter ('bbp_get_topic_content', 'add_image_responsive_class');
oops .. fatal error ..
trying to beat the other side. next digging towards how to open an innocent picture with target = “_ self” through css trick..
task narrowed! )
might be taking out spaces after the $ signs eg
return $ content;
should be
return $content;
ok ok – fixed a lot of syntax errors. Now the code looks like this and it works
function add_image_responsive_class($content) {
global $post;
$pattern ="/<img(.*?)class=\"(.*?)\"(.*?)>/i";
$replacement = '<img $1class="$2 img-responsive"$3>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter ('bbp_get_reply_content', 'add_image_responsive_class');
add_filter ('bbp_get_topic_content', 'add_image_responsive_class');
Summary. I got a new picture class – img-responsive. But no new link appeared. How to make it open like a rel prettyPhoto … no ideas yet ..
A feature is at stake – to allow all BBPforum pictures the last few years to open in a lightbox in full size. worth looking for a solution)
ok, so do you have a link to an example that works (say in worpress) and one that doesn’t in bbpress?
Ok, if it’s not difficult for you. This is a fake sandbox, sorry for the mess.
dev.imhodom.ru/forums/topic/%d0%b0-%d0%b5%d1%81%d0%bb%d0%b8-%d0%bd%d0%b5-%d0%b7%d0%b0%d0%b3%d1%80%d1%83%d0%b6%d0%b0%d1%82%d1%8c-%d0%b0-%d0%b8%d0%b7-%d0%b1%d0%b8%d0%b1%d0%b8%d0%bb%d0%b8%d0%be%d1%82%d0%b5%d0%ba%d0%b8-%d0%b2/#post-256485
see#post-256485. The top large picture is an old regular one. We are trying for.
The bottom picture is how it should work.
PS – The new pics class in functions is disabled now, but enable if needed, no problem.
@neon67
HI @neon67
I want to implement lightbox in bbpress like you do.
beside creating the function below, what else should I do?
Please share me installed plugins and other information
###############################################################
function add_image_responsive_class($content) {
global $post;
$pattern =”/<img(.*?)class=\”(.*?)\”(.*?)>/i”;
$replacement = ‘‘;
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter (‘bbp_get_reply_content’, ‘add_image_responsive_class’);
add_filter (‘bbp_get_topic_content’, ‘add_image_responsive_class’);
################################################
Best Regards,
Hyunho
The easiest way is to install the GD attachments plugin – and in the settings note something like a class = ”my-class” rel = ”prettyPhoto”
In addition, your WP must have a lightbox mechanism on board – there are many lightbox plugins in the repository. This script will to command light box style when you click on the picture.
But I went the other way – I added a class with a new relay through the filters – and the lightbox mechanism is already built into my bbp-theme. This also works.
Hi @neon67
Thanks to reply
Did you use the “prettyphoto” plugin?
(https://wordpress.org/plugins/prettyphoto)
Best Regards,
Hyunho
Hi
i finally solved it with your idea, and i modified the function a little bit
function add_image_responsive_class($content) {
global $post;
$pattern ="/<img src=\"(.*?)\"(.*?)>/i";
$replacement = '<a href="$1" rel="prettyPhoto"><img src="$1"/>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter ('bbp_get_reply_content', 'add_image_responsive_class');
add_filter ('bbp_get_topic_content', 'add_image_responsive_class');
thanks
Best Regards,
Hyunho
Oh! mistake
did not close the tag “< / a>”
$replacement = '<a href="$1" rel="prettyPhoto"><img src="$1"/>';
to
$replacement = '<a href="$1" rel="prettyPhoto"><img src="$1"/></a>';