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