Plugins » Nivo Slider for gp|Easy 1.0.6

Hyperlinked images
Topic Closed
andrew
14 Posts

I made some changes to the plugin so that if there are .LNK files the image will become a clickable link.
e.g. image.png, image.lnk contains text: http://www.test.com/, when image.png shows on the slideshow, clicking anywhere on it will follow that link.

This is of course just using the functionality already present in nivo jquery, which recognizes an <a> tag enclosing an <img> tag.

Here is my modification of your code:

foreach ($slide_images as &$value) {
                $linkMade = false; // capture whether or not a closing </a> will be needed
                // I suppose something should be added to the config to control behavior properly
                if ($this->config['captions']=='textfiles') {
                    $txt_file = substr($value,0,strrpos($value, '.')).".lnk"; // message($txt_file);
                    $TXT_file = substr($value,0,strrpos($value, '.')).".LNK"; // message($TXT_file);
                    // DEBUG  echo ' txtfile="'.$txt_file.'" bool="'.(in_array($txt_file, $slide_captions)).'"';
                    $myTxtFile = false;
                    if (in_array($txt_file, $slide_links)) { $myTxtFile = $txt_file; }
                    if (in_array($TXT_file, $slide_links)) { $myTxtFile = $TXT_file; }
                    if ($myTxtFile) {
                        $fh = fopen($myTxtFile, 'r');
                        $Linkdata = fread($fh, filesize($myTxtFile));
                        fclose($fh);
                        echo ' <a class="gpE_nivo_slide" id="gpE_nivo_link_'.$slidenumber.'" href="'.$Linkdata.'">';
                        $linkMade = true;
                    }
 
                }
                echo '  <img class="gpE_nivo_slide" id="gpE_nivo_slide_'.$slidenumber.'" alt=""';
 
                if ($this->config['captions']=='filenames') {
                    $fileNameCaption = str_replace('_',' ',substr(basename($value),0,strrpos(basename($value), '.')));
                    echo ' title="'.$fileNameCaption.'"';
                }
 
                if ($this->config['captions']=='textfiles') {
                    $txt_file = substr($value,0,strrpos($value, '.')).".txt"; // message($txt_file);
                    $TXT_file = substr($value,0,strrpos($value, '.')).".TXT"; // message($TXT_file);
                    // DEBUG  echo ' txtfile="'.$txt_file.'" bool="'.(in_array($txt_file, $slide_captions)).'"';
                    $myTxtFile = false;
                    if (in_array($txt_file, $slide_captions)) { $myTxtFile = $txt_file; }
                    if (in_array($TXT_file, $slide_captions)) { $myTxtFile = $TXT_file; }
                    if ($myTxtFile) {
                        $fh = fopen($myTxtFile, 'r');
                        $HTMLdata = fread($fh, filesize($myTxtFile));
                        fclose($fh);
                        echo ' title="#gpE_nivoTxtCaption_'.$slidenumber.'"';
                        $HTMLcaptions .= '<div id="gpE_nivoTxtCaption_'.$slidenumber.'" class="nivo-html-caption">'.$HTMLdata.'</div>';
                    }
                }
 
                //DEBUG  message(htmlspecialChars($HTMLcaptions)."-<br/>");
 
                if ($this->config['slideStyles']!='') { echo ' style="'.$this->config['slideStyles'].'"'; }
 
                echo ' src="'.$dirPrefix.'/data/_uploaded'.$this->config['imagepath'].'/'.basename($value).'"';
                echo ' data-thumb="'.$dirPrefix.'/data/_uploaded'.$this->config['imagepath'].'/'.basename($value).'"';
                echo ' />'."\n";
                if($linkMade == true) { echo '</a>'; }
                $slidenumber++;
            }

Then the function getAllLinkfiles is no different except for what file extension it looks for:

function getAllLinkfiles($txtdir) {
    $allTextfiles = array();
    $dtxt = opendir($txtdir);
    while($txtfile = readdir($dtxt)) {
        if(strtolower(substr($txtfile,-3)) === "lnk") {
            $allTextfiles[] = $txtdir.$txtfile;
        }
    }
    return $allTextfiles;
}

 

4 years ago#7730

Topic Closed

 

News

Typesetter 5.1
8/12/2017

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register