Home › Forums › General Issues › Photoswipe lightbox does't detect image field (solved) › Reply To: Photoswipe lightbox does't detect image field (solved)
This might only work in photoswipe. What the plugin usually does is find images in your the_content(), and adds ‘data-size’ to them as a href value to make sure the plugin knows that should be a lightbox image.
What I did was put this into my functions.php:
function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) {
$html = sprintf('<a class="fancybox-img" href="%1$s"><img alt="%2$s" src="%1$s" data-size="2080x890" /></a>', esc_attr(esc_url($url)), esc_attr($title));
return $html;
}
add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 8);
I pulled it from another thread, but it works. Now just have to figure out how to get data-size to be a dynamic value instead of static, but that isn’t related to ACF anymore
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.