• When viewing an attachment page for a pdf your plugin is trying to lightbox the link, which results in the following error: “Image cannot be loaded. Make sure the path is correct and image exist.”

    I tracked it down to the add_gallery_lightbox_selector function. The code doesn’t seem to be checking that it’s an image like you do in add_links_lightbox_selector.

    I took your regex from there and applied it to this function and now it’s working as (I) expected–

    public function add_gallery_lightbox_selector($link, $id, $size, $permalink, $icon, $text)
    {
    	if (preg_match('/<a(.*?)href=(?:\'|")([^<]*?).(bmp|gif|jpeg|jpg|png)(?:\'|")(.*?)>/i', $link) === 1) {
    		$link = (preg_match('/<a.*? rel=("|\').*?("|\')>/', $link) === 1 ? preg_replace('/(<a.*? rel=(?:"|\').*?)((?:"|\').*?>)/', '$1 ' . $this->options['settings']['selector'] . '[gallery-' . $this->gallery_no . ']' . '$2', $link) : preg_replace('/(<a.*?)>/', '$1 rel="' . $this->options['settings']['selector'] . '[gallery-' . $this->gallery_no . ']' . '">', $link));
    
    		return (preg_match('/<a.*? href=("|\').*?("|\')>/', $link) === 1 ? preg_replace('/(<a.*? href=(?:"|\')).*?((?:"|\').*?>)/', '$1' . wp_get_attachment_url($id) . '$2', $link) : preg_replace('/(<a.*?)>/', '$1 href="' . wp_get_attachment_url($id) . '">', $link));
    	} else {
    		return $link;
    	}
    }

    https://www.ads-software.com/plugins/responsive-lightbox/

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with add_gallery_lightbox_selector’ is closed to new replies.