Code Monkey home page Code Monkey logo

dokuwiki-plugin-gallery's Introduction

gallery Plugin for DokuWiki

All documentation for this plugin can be found at
http://www.dokuwiki.org/plugin:gallery

If you install this plugin manually, make sure it is installed in
lib/plugins/gallery/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) Andreas Gohr <[email protected]>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

See the COPYING file in your DokuWiki folder for details

dokuwiki-plugin-gallery's People

Contributors

akhzz905 avatar alexgearbox avatar android405 avatar annda avatar araname avatar bellingeri avatar brilanto avatar crystal-rainslide avatar dturkalj avatar fukuyori avatar gringit avatar irifat avatar kastra28 avatar macsenny avatar micgro42 avatar michitux avatar mprins avatar naveenvenugopal avatar nfriedli avatar nimahamidian avatar oott123 avatar pijoter avatar powerslave avatar qezwan avatar schplurtz avatar splitbrain avatar unixhex avatar yllelder avatar zastarbe avatar zweihorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dokuwiki-plugin-gallery's Issues

Feature wish: responsive design

Dokuwiki becomes better and better on mobile devices. Your changes for audio and video in the latest release and earlier the vshare changes made our site more compatible with mobile devices. Two plugins we use are still not mobile aware. One of them is the gallery plugin. We wish it would become responsive towards smaller screens. Resize the images and keep the amount of columns or change the amount of columns based on screensize. Both options are fine with us.

renders site unusable after upgrade to Frusterick Manners

After an upgrade to Frusterick Manners my dokuwiki site seemed to be
broken in a weird way. The pages render like they should when loaded
from the address line of the browser. Unfortunately, a left-mouse-button
click anywhere on the page immediately blacks-out. The view is not
completely black, just very dark. The content of the page can still be
seen as a faint shadow. There is a medium sized white cross in the upper
right. A scroll bar on the right still works. I can zoom in with
CTRL+scroll_wheel. But left-mouse-clicks on links or buttons do not seem
to have any effect at all.

These problems affected all dokuwiki pages, including admin and login.

On the developer mailing list Markus Hitter hinted, that swipebox may be
the culprit. Apparently, the gallery plugin makes heavy use of this tool.
After I moved the gallery plugin out of the way, my site became usable again.

---<)kaimartin(>---

Images not as <img> but as background

Setting the <img> as background has the advantage of easier styling. for instance, "border-radius" can work. Other things (like css3 transformations of reflections" do also work (just a little bit) better on backgrounds.

#Line 562
        // prepare output
        $ret  = '';
        $ret .= '<center>';
        $ret .= '<a href="'.$href.'" '.$aatt.'>';
        $ret .= '<div style="width:'.$w.'px; height:'.$h.'px; background-image: url('.$src.');" '.$iatt.'></div>';
        $ret .= '</a>';
        $ret .= '</center>';
        return $ret;

The nice thing is, that the <center> tags do have NO EFFECT !! So the images are still displayed on the left of each <td> (thanks to the CSS float: left of the original plugin). But if this behaviour is not intended a "float:none" in the userstyles.css can fix it. :-)

file premissions in download

Rights on directory plugin is not wel set. Use this command in "lib/plugin" to correct rights:

find ./ -type f -exec chmod o+r '{}' ;
find ./ -type d -exec chmod o+rx '{}' ;

Comments for Images

Use this syntax.php if you want comments for your images.

  <gallery images:vacation?image_*.jpg&80x80&crop&lightbox>
  image.jpg=Comment for image 
  image2.jpg=second comment for another image 
  </gallery>
<code>
<?php
/**
 * Embed an image gallery
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <[email protected]>
 * @author     Joe Lapp <[email protected]>
 * @author     Dave Doyle <davedoyle.canadalawbook.ca>
 * @author     Gerry Weissbach <[email protected]>
 */

if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
require_once(DOKU_INC.'inc/search.php');
require_once(DOKU_INC.'inc/JpegMeta.php');

class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Andreas Gohr',
            'email'  => '[email protected]',
            'date'   => '2007-11-06',
            'name'   => 'Gallery Plugin',
            'desc'   => 'Creates a gallery of images from a namespace',
            'url'    => 'http://wiki.splitbrain.org/plugin:gallery',
        );
    }

    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }

    /**
     * What about paragraphs?
     */
    function getPType(){
        return 'block';
    }

    /**
     * Where to sort in?
     */
    function getSort(){
        return 301;
    }


    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
        //$this->Lexer->addSpecialPattern('\{\{gallery>[^}]*\}\}',$mode,'plugin_gallery');
        $this->Lexer->addSpecialPattern('<gallery.*?>.+?</gallery>',$mode,'plugin_gallery');
    }


    /**
     * Parse option
     */
    function parseOpt($params, $name) {
        if(preg_match('/\b'.$name.'\b/i',$params,$match)) {
        return true;
        }else if(preg_match('/\bno'.$name.'\b/i',$params,$match)) {
        return false;
    }else{
            return $this->getConf($name);
        }
    }

    /**
     * Handle the match
     */
    function handle($all_match, $state, $pos, &$handler){
        //$match = substr($match,10,-2); //strip markup from start and end

        $data = array();

        //handle params
        //list($ns,$params) = explode('?',$match,2);
    preg_match("#<gallery(.*?)>#", $all_match, $para);
    list($ns,$params) = explode('?',$para[1],2);

        /*if ( substr($ns, 0, 1) == ' ' )
            $data['float']="right";
        else if ( substr($ns, -1) == ' ' )
            $data['float']="left";
        else
            $data['float'] = null;
    */
        //namespace
        $data['ns'] = $ns;

        //max thumb dimensions
        if(preg_match('/\b(\d+)x(\d+)\b/',$params,$match)){
            $data['w'] = $match[1];
            $data['h'] = $match[2];
        }else{
            $data['w'] = $this->getConf('thumbnail_width');
            $data['h'] = $this->getConf('thumbnail_height');
        }

        //max lightbox dimensions
        if(preg_match('/\b(\d+)X(\d+)\b/',$params,$match)){
            $data['w_lightbox'] = $match[1];
            $data['h_lightbox'] = $match[2];
        }else{
            $data['w_lightbox'] = $this->getConf('image_width');
            $data['h_lightbox'] = $this->getConf('image_height');
        }

        //number of images per row
        if(preg_match('/\b(\d+)\b/i',$params,$match)){
            $data['cols'] = $match[1];
        }else{
            $data['cols'] = $this->getConf('cols');
        }

        //show the filename
        $data['showname'] = $this->parseOpt($params, 'showname');

        //lightbox style?
        $data['lightbox'] = $this->parseOpt($params, 'lightbox');

        //direct linking?
        if($data['lightbox']) {
            $data['direct']   = true; //implicit direct linking
        }else{
            $data['direct'] = $this->parseOpt($params, 'direct');
        }

        //reverse sort?
        $data['reverse'] = $this->parseOpt($params, 'reverse');

        //resize thing?
        if(preg_match('/\bnoresize\b/i',$params,$match)) {
            $data['noresize'] = true;
        }else{
            $data['noresize'] = false;
        }

        //Layout thing?
        if(preg_match('/\bmagazine\b/i',$params,$match)) {
            $data['magazine'] = true;
        }else{
            $data['magazine'] = false;
        }

        //Layout thing?
        if(preg_match('/\bdiashow\b/i',$params,$match)) {
            $data['diashow'] = true;
        }else{
            $data['diashow'] = false;
        }

        //Layout thing?
        if(preg_match('/\bpageAmount=(\d+)\b/i',$params,$match)) {
            $data['pageAmount'] = $match[1];
        }else{
            $data['pageAmount'] = -1;
        }

    $match    = preg_replace('#<gallery.*?>|</gallery>#', '', $all_match);
    $match = preg_split ('#\n#',$match);
    foreach ($match as $line){
        list($name,$comment) = explode('=',$line,2);    
        $data['comments'][$name]=$comment;    
    }

        return $data;
    }

    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if ( $data['pageAmount'] > 0 ) $renderer->info['cache'] = FALSE;

        if($mode == 'xhtml'){
            $renderer->doc .= $this->_gallery($data);
            return true;
        }
        return false;
    }

    /**
     * Does the gallery formatting
     */
    function _gallery($data){
        global $conf;
        global $lang;
        $ret = '';

        //use the search to get all files
        $ns = cleanID($data['ns']);
        $dir = utf8_encodeFN(str_replace(':','/',$ns));
        $files = array();
        search($files,$conf['mediadir'],'search_media',array(),$dir);

        //anything found?
        if(!count($files)){
            $ret .= '<div class="nothing"><pre>'.$lang['nothingfound'].print_r($data,$return=true).'</pre></div>';
            return $ret;
        }

        //reverse if wanted
        if($data['reverse']) rsort($files);

        //startPoint of Pages
        $startPoint = intval($_REQUEST['startPoint']);


        // build magazine
        if ($data['magazine'])
        {
            require_once(realpath(dirname(__FILE__)).'/inc/magazinelayout.class.php');

            $template = '<img src="/lib/plugins/gallery/inc/image.php?size=[size]&file=[image]" alt="" />';
            $mag = new magazinelayout($data['w'], $data['h']!=120?$data['h']:5, $template);
            $cols = $data['cols'];
            $cols = $cols > 8 ? 8 : $cols;

//          $content = '<div class="gallery">';

            $amount = 0;
            foreach($files as $img){
                if(!$img['isimg']) continue;
                $amount ++;
                if ( $amount < $startPoint ) continue;
                if ( $data['pageAmount'] > 0 && $amount-$startPoint >= $data['pageAmount'] ) break;

                $img['lightbox'] = $data['lightbox'];
                $img['h_lightbox'] = $data['h_lightbox'];
                $img['w_lightbox'] = $data['w_lightbox'];
                $img['direct'] =  $data['direct'];
                $img['float'] =  $data['float'];

                $mag->addImage($img);

                $cols --;
                if ($cols <= 0 )
                {
                    $content .= $mag->getHtml();
                    $mag = new magazinelayout($data['w'], $data['h']!=120?$data['h']:5, $template);
                    $cols = $data['cols'];
                }

            }

            if ($mag->_numimages > 0) $content .= $mag->getHtml();

//          $content .= '<br style="clear:both" /></div></div></div>';

            $content .= $this->_pageSelect(count($files), $data['pageAmount'], $startPoint);
            return $content;
        }


        // build gallery
        if($data['cols'] > 0){ // format as table
            $ret .= '<table class="gallery"' . (!empty($data['float']) ? ' style="float: '.$data['float'].';"' : '') . '>';
            $i = 0;
            $amount = 0;
            foreach($files as $img){
                if(!$img['isimg']) continue;
                $amount ++;
                if ( $amount < $startPoint ) continue;
                if ( $data['pageAmount'] > 0 && $amount-$startPoint >= $data['pageAmount'] ) break;

                if($i == 0){
                    $ret .= '<tr>';
                }

                $ret .= '<td>';
                $ret .= $this->_image($img,$data);
                $ret .= $this->_showname($img,$data);
        $ret .= $this->_showcomment($img,$data);
                $ret .= '</td>';

                $i++;

                $close_tr = true;
                if($i == $data['cols']){
                    $ret .= '</tr>';
                    $close_tr = false;
                    $i = 0;
                }
            }

            if ($close_tr){
                // add remaining empty cells
                for(;$i < $data['cols']; $i++){
                    $ret .= '<td></td>';
                }
                $ret .= '</tr>';
            }

            $ret .= '</table>';
        }else{ // format as div sequence
            $ret .= '<div class="gallery"' . (!empty($data['float']) ? ' style="float: '.$data['float'].';"' : '') . '>';

            $amount = 0;
            foreach($files as $img){
                if(!$img['isimg']) continue;
                $amount ++;
                if ( $amount < $startPoint ) continue;
                if ( $data['pageAmount'] > 0 && $amount-$startPoint >= $data['pageAmount'] ) break;

                $ret .= '<div>';
                $ret .= $this->_image($img,$data);
                $ret .= $this->_showname($img,$data);
        $ret .= $this->_showcomment($img,$data);
                $ret .= '</div> ';
            }

            $ret .= '<br style="clear:both" /></div>';
        }

        $ret .= $this->_pageSelect(count($files), $data['pageAmount'], $startPoint);
        return $ret;
    }

    /**
     * Defines how a thumbnail should look like
     */
    function _image($img,$data){
        global $ID;

        $w = $img['meta']->getField('File.Width');
        $h = $img['meta']->getField('File.Height');
        $dim = array();

        if ( $data['noresize'])
        {
            $w = $data['w'];
            $h = $data['h'];
        }
        else if($w > $data['w'] || $h > $data['h']){
            $ratio = $img['meta']->getResizeRatio($data['w'],$data['h']);
            $w = floor($w * $ratio);
            $h = floor($h * $ratio);
            $dim = array('w'=>$w,'h'=>$h);
        }

        //prepare img attributes
        $i           = array();
        $i['width']  = $w;
        $i['height'] = $h;
        $i['border'] = 0;
        $i['alt']    = $img['meta']->getField('Simple.Title');
        $i['class']  = 'tn';
        $iatt = buildAttributes($i);
        $src  = ml($img['id'],$dim);

        // prepare lightbox dimensions
        $w_lightbox = $img['meta']->getField('File.Width');
        $h_lightbox = $img['meta']->getField('File.Height');
        $dim_lightbox = array();
        if($w_lightbox > $data['w_lightbox'] || $h_lightbox > $data['h_lightbox']){
            $ratio = $img['meta']->getResizeRatio($data['w_lightbox'],$data['h_lightbox']);
            $w_lightbox = floor($w_lightbox * $ratio);
            $h_lightbox = floor($h_lightbox * $ratio);
            $dim_lightbox = array('w'=>$w_lightbox,'h'=>$h_lightbox);
        }

        //prepare link attributes
        $a           = array();
        $a['title']  = $img['meta']->getField('Simple.Title');
        if($data['lightbox']){
            $href   = ml($img['id'],$dim_lightbox);
            $a['class'] = "lightbox JSnocheck";
            $a['rel']   = "lightbox";
        }else{
            $href   = ml($img['id'],array('id'=>$ID),$data['direct']);
        }
        $aatt = buildAttributes($a);

        // prepare output
        $ret  = '';
        $ret .= '<a href="'.$href.'" '.$aatt.'>';
        $ret .= '<img src="'.$src.'" '.$iatt.' />';
        $ret .= '</a>';
        return $ret;
    }


    /**
     * Defines how a filename + link should look
     */
    function _showname($img,$data){
        global $ID;

        if(!$data['showname']) { return ''; }

        //prepare link
        $lnk = ml($img['id'],array('id'=>$ID),false);

        // prepare output
        $ret  = '';
        $ret .= '<br /><a href="'.$lnk.'">';
        $ret .= $img['file']; // see fix posted on the wiki
        $ret .= '</a>';
        return $ret;
    }

    /**
     * Defines how a comment should look
     */
    function _showcomment($img,$data){
        global $ID;

        // prepare output
        $ret  = '';
        $ret .= '<br />';
        $ret .= $data['comments'][$img['file']]; 

        return $ret;
    }

    function _pageSelect($fileCount, $showCount, $startPoint)
    {
        global $ID;
        $content = '<div id="pageSelect">';

        $pages = ceil($fileCount / $showCount);
        if ( $pages <= 1 ) return "";

        for ($i=0; $i<$pages; $i++)
        {
            $lnk = wl($ID, array('startPoint'=>$i*$showCount));
            $content .= '<a href="' . $lnk . '">';
            $content .= $i+1;
            $content .= '</a>';

            if ( $i < $pages -1 )
                $content .= '&nbsp;-&nbsp;';
        }

        $content .= '</div>';
        return $content;
    }
}

//Setup VIM: ex: et ts=4 enc=utf-8 :
</code>

Make the border configurable

I tried to use the gallery plugin as a dropin replacement to view images with lightbox.

Unfortunately the tags are different and I cannot find a way to disable the css border of the images.

Maybe you could make the border, margin and padding stuff configurable or add a flag to use the global theme tags.

Nothing found for certain feeds

Hi,

I can't tell the difference on both rss feeds:
example
and something like this:
other feed
The example works fine, but the other one does not.

I tried to use it like this:
{{gallery>http://www.comicsyndicate.org/Feed/Dilbert?lightbox}}

Is anyone able to recreate this issue? And how can I fix this?

XSS vulnerability in dokuwiki gallery plugin

Hi,

I discoverd a little XSS vulnerability in the Dokuwiki gallery plugin. It looks like the output in the lightbox isn't sanitized correctly. I've injected some nice HTML tags with exiftool into a jpg and in lightbox mode they are shown. The function media_contentcheck prevents the upload of such images, but not in every case. It checks just the first 256 bytes of an image, but if you have a big EXIF header (from a digtal camera) this is not enough.

Lightbox does not work well on mobile devices

Just started using this plugin short while ago. It is great! The only thing is that the lightbox mode does not work well on mobile devices. Is there any upgrade? I looked at "lightbox2", and that works great on mobile devices. Does anyone know how hard it would be to replace prettyphoto with another lightbox script, like litebox2 for example? It is located here:
http://lokeshdhakar.com/projects/lightbox2/

Include/Exclude images form gallery

Syntax:

{{gallery>namespace?some&params}}
or
{{gallery>
namespace?some&params
+other:namespace:image.jpg|optional title
-my:namespace
-their:namespace:image.jpg
}}

additionally:

  • images included in gallery could have their own title (take precedence over meta title)
  • paginate menu will be shown only if there are more images than ~num parameter
  • lightboxForEveryImg now works with dokuwiki 2010
  • galleries are aligned to the left by default
  • gallery could be created from many independent namespaces or files (include/exclude images/galleries)

I do not use rss features of the gallery plugin so - could be broken with following changes.

Pijoter.

diff --git a/script.js b/script.js
index 21c90d6..e35026b 100644
--- a/script.js
+++ b/script.js
@@ -49,7 +49,7 @@
  *
  * If you don't like that behavior, set this variable to 0.
  */
-var lightboxForEveryImg = 0;
+var lightboxForEveryImg = 1;

 function WindowSize()
 { // window size object
@@ -162,7 +162,7 @@ LightBox.prototype = {
                   anchor.getAttribute("class").match("media") &&
                   anchor.firstChild.nodeName.toLowerCase().match("img") &&
                   anchor.getAttribute("href") &&
-                  anchor.getAttribute("href").match("lib/exe/fetch.php|_media/")) ){
+                  anchor.getAttribute("href").match("lib/exe/fetch.php|_media/|_detail/")) ){
                 // okay add lightbox
             }else{
                 continue;
@@ -171,14 +171,15 @@ LightBox.prototype = {

             // initialize item
             self._imgs[num] = {src:anchor.getAttribute("href"),w:-1,h:-1,title:'',caption:'',cls:anchor.className};
-            if (anchor.getAttribute("title"))
-                self._imgs[num].title = anchor.getAttribute("title");
-            else if (anchor.firstChild && anchor.firstChild.getAttribute && anchor.firstChild.getAttribute("title"))
+            if (anchor.firstChild && anchor.firstChild.getAttribute && anchor.firstChild.getAttribute("title"))
                 self._imgs[num].title = anchor.firstChild.getAttribute("title");
+            else if (anchor.getAttribute("title"))
+                self._imgs[num].title = anchor.getAttribute("title");
             if (anchor.firstChild && anchor.firstChild.getAttribute &&
                 anchor.firstChild.getAttribute("longdesc")) {
                 self._imgs[num].caption = anchor.firstChild.getAttribute("longdesc");
             }
+            if(lightboxForEveryImg) self._imgs[num].src = anchor.getAttribute("href").replace("_detail/","_media/");
             anchor.onclick = self._genOpener(num); // set closure to onclick event
         }
         var body = d.getElementsByTagName("body")[0];

diff --git a/style.css b/style.css
index dff7a3a..2a142b6 100644
--- a/style.css
+++ b/style.css
@@ -14,9 +14,9 @@ div.dokuwiki div.gallery {
   margin-bottom: 1em;
 }

-/*div.dokuwiki div.gallery div {
+div.dokuwiki div.gallery div {
   float: left;
-}*/
+}

 div.dokuwiki div.gallery img.tn {
   margin: 9px;
@@ -30,13 +30,17 @@ div.dokuwiki div.gallery_left {
 }

 div.dokuwiki div.gallery div {
-    float: left;
+    /*float: left;*/
 }

 div.dokuwiki div.gallery_right {
     float: right;
 }

+div.dokuwiki div.gallery_normal {
+    /*width: 90%;*/
+}
+
 div.dokuwiki div.gallery_center {
     margin-left: auto;
     margin-right: auto;

diff --git a/syntax.php b/syntax.php
index 181aca2..d6ae078 100644
--- a/syntax.php
+++ b/syntax.php
@@ -42,7 +42,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
      * Connect pattern to lexer
      */
     function connectTo($mode) {
-        $this->Lexer->addSpecialPattern('\{\{gallery>[^}]*\}\}',$mode,'plugin_gallery');
+        $this->Lexer->addSpecialPattern('\{\{(?:galeria|gallery)>[^}]*\}\}',$mode,'plugin_gallery');
     }

     /**
@@ -50,95 +50,102 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
      */
     function handle($match, $state, $pos, &$handler){
         global $ID;
-        $match = substr($match,10,-2); //strip markup from start and end
-
-        $data = array();
-
-        $data['galid'] = substr(md5($match),0,4);
-
-        // alignment
-        $data['align'] = 0;
-        if(substr($match,0,1) == ' ') $data['align'] += 1;
-        if(substr($match,-1,1) == ' ') $data['align'] += 2;
-
-        // extract params
-        list($ns,$params) = explode('?',$match,2);
-        $ns = trim($ns);
-
-        // namespace (including resolving relatives)
-        if(!preg_match('/^https?:\/\//i',$ns)){
-            $data['ns'] = resolve_id(getNS($ID),$ns);
-        }else{
-            $data['ns'] =  $ns;
-        }
-
-        // set the defaults
-        $data['tw']       = $this->getConf('thumbnail_width');
-        $data['th']       = $this->getConf('thumbnail_height');
-        $data['iw']       = $this->getConf('image_width');
-        $data['ih']       = $this->getConf('image_height');
-        $data['cols']     = $this->getConf('cols');
-        $data['filter']   = '';
-        $data['lightbox'] = false;
-        $data['direct']   = false;
-        $data['showname'] = false;
-        $data['showtitle'] = false;
-        $data['reverse']  = false;
-        $data['random']   = false;
-        $data['cache']    = true;
-        $data['crop']     = false;
-        $data['recursive']= true;
-        $data['sort']     = $this->getConf('sort');
-        $data['limit']    = 0;
-        $data['offset']   = 0;
-        $data['paginate'] = 0;
-
-        // parse additional options
-        $params = $this->getConf('options').','.$params;
-        $params = preg_replace('/[,&\?]+/',' ',$params);
-        $params = explode(' ',$params);
-        foreach($params as $param){
-            if($param === '') continue;
-            if($param == 'titlesort'){
-                $data['sort'] = 'title';
-            }elseif($param == 'datesort'){
-                $data['sort'] = 'date';
-            }elseif($param == 'modsort'){
-                $data['sort'] = 'mod';
-            }elseif(preg_match('/^=(\d+)$/',$param,$match)){
-                $data['limit'] = $match[1];
-            }elseif(preg_match('/^\+(\d+)$/',$param,$match)){
-                $data['offset'] = $match[1];
-            }elseif(is_numeric($param)){
-                $data['cols'] = (int) $param;
-            }elseif(preg_match('/^~(\d+)$/',$param,$match)){
-                $data['paginate'] = $match[1];
-            }elseif(preg_match('/^(\d+)([xX])(\d+)$/',$param,$match)){
-                if($match[2] == 'X'){
-                    $data['iw'] = $match[1];
-                    $data['ih'] = $match[3];
-                }else{
-                    $data['tw'] = $match[1];
-                    $data['th'] = $match[3];
-                }
-            }elseif(strpos($param,'*') !== false){
-                $param = preg_quote($param,'/');
-                $param = '/^'.str_replace('\\*','.*?',$param).'$/';
-                $data['filter'] = $param;
+        $match = substr($match,strpos($match,'>')+1,-2); //strip markup from start and end
+        $items = preg_split('/[\n]/', trim($match));
+
+        $containter = array();
+        foreach ($items as $item) {
+            $data = array();
+            $data['galid'] = substr(md5($item),0,4);
+
+            // alignment
+            $data['align'] = 0;
+            if(substr($match,0,1) == ' ') $data['align'] += 1;
+            if(substr($match,-1,1) == ' ') $data['align'] += 2;
+
+            // extract params
+            list($ns,$params) = explode('?',$item,2);
+            $data['op'] = ($ns[0] != '-')? 'merge' : 'diff';
+            $ns = ($ns[0] == '-' || $ns[0] == '+')? substr($ns,1) : trim($ns);
+            list($ns,$title) = explode('|',$ns,2);
+            $data['title'] = $title;
+
+            // namespace (including resolving relatives)
+            if(!preg_match('/^https?:\/\//i',$ns)){
+                $data['ns'] = resolve_id(getNS($ID),$ns);
             }else{
-                if(substr($param,0,2) == 'no'){
-                    $data[substr($param,2)] = false;
+                $data['ns'] =  $ns;
+            }
+
+            // set the defaults
+            $data['tw']       = $this->getConf('thumbnail_width');
+            $data['th']       = $this->getConf('thumbnail_height');
+            $data['iw']       = $this->getConf('image_width');
+            $data['ih']       = $this->getConf('image_height');
+            $data['cols']     = $this->getConf('cols');
+            $data['filter']   = '';
+            $data['lightbox'] = false;
+            $data['direct']   = false;
+            $data['showname'] = false;
+            $data['showtitle'] = false;
+            $data['reverse']  = false;
+            $data['random']   = false;
+            $data['cache']    = true;
+            $data['crop']     = false;
+            $data['recursive']= true;
+            $data['sort']     = $this->getConf('sort');
+            $data['limit']    = 0;
+            $data['offset']   = 0;
+            $data['paginate'] = 4;
+
+            // parse additional options
+            $params = $this->getConf('options').','.$params;
+            $params = preg_replace('/[,&\?]+/',' ',$params);
+            $params = explode(' ',$params);
+            foreach($params as $param){
+                if($param === '') continue;
+                if($param == 'titlesort'){
+                    $data['sort'] = 'title';
+                }elseif($param == 'datesort'){
+                    $data['sort'] = 'date';
+                }elseif($param == 'modsort'){
+                    $data['sort'] = 'mod';
+                }elseif(preg_match('/^=(\d+)$/',$param,$match)){
+                    $data['limit'] = $match[1];
+                }elseif(preg_match('/^\+(\d+)$/',$param,$match)){
+                    $data['offset'] = $match[1];
+                }elseif(is_numeric($param)){
+                    $data['cols'] = (int) $param;
+                }elseif(preg_match('/^~(\d+)$/',$param,$match)){
+                    $data['paginate'] = $match[1];
+                }elseif(preg_match('/^(\d+)([xX])(\d+)$/',$param,$match)){
+                    if($match[2] == 'X'){
+                        $data['iw'] = $match[1];
+                        $data['ih'] = $match[3];
+                    }else{
+                        $data['tw'] = $match[1];
+                        $data['th'] = $match[3];
+                    }
+                }elseif(strpos($param,'*') !== false){
+                    $param = preg_quote($param,'/');
+                    $param = '/^'.str_replace('\\*','.*?',$param).'$/';
+                    $data['filter'] = $param;
                 }else{
-                    $data[$param] = true;
+                    if(substr($param,0,2) == 'no'){
+                        $data[substr($param,2)] = false;
+                    }else{
+                        $data[$param] = true;
+                    }
                 }
             }
-        }

-        // implicit direct linking?
-        if($data['lightbox']) $data['direct']   = true;
+            // implicit direct linking?
+            if($data['lightbox']) $data['direct']   = true;
+            //XXX if (count($items)>1) $data['sort'] = 'unsorted';

-
-        return $data;
+            $containter[] = $data;
+        }
+        return $containter;
     }

     /**
@@ -236,7 +243,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
                     'isimg' => preg_match('/\.(jpe?g|gif|png)$/',$dir),
                     'file'  => basename($dir),
                     'mtime' => filemtime($conf['mediadir'].'/'.$dir),
-                    'meta'  => new JpegMeta($conf['mediadir'].'/'.$dir)
+                    'meta'  => new JpegMeta($conf['mediadir'].'/'.$dir),
+                    'title' => $data['title']
                 );
                 $data['_single'] = true;
             }else{
@@ -322,12 +330,25 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
     /**
      * Does the gallery formatting
      */
+    function _filescomp($a,$b) {return strcmp($a['id'],$b['id']);}
     function _gallery($data){
         global $conf;
         global $lang;
         $ret = '';

-        $files = $this->_findimages($data);
+        $files = array();
+        foreach ($data as $item) {
+            $f = $this->_findimages($item);
+            if ($item['op'] == 'merge') {
+                // pozbadz sie duplikatow
+                $intersect = array_uintersect($files,$f,array($this,'_filescomp'));
+                if (count($intersect)) $f = array_udiff($f,$intersect,array($this,'_filescomp'));
+                $files = array_merge($files,$f);
+            }
+            else {
+                $files = array_udiff($files,$f,array($this,'_filescomp'));
+            }
+        }

         //anything found?
         if(!count($files)){
@@ -335,6 +356,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
             return $ret;
         }

+        $data = $data[0];
+
         // prepare alignment
         $align = '';
         $xalign = '';
@@ -351,8 +374,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
             $xalign = ' align="center"';
         }
         if(!$data['_single']){
-            if(!$align) $align = ' gallery_center'; // center galleries on default
-            if(!$xalign) $xalign = ' align="center"';
+            if(!$align) $align = ' gallery_normal'; // left align galleries on default
+            if(!$xalign) $xalign = ' align="left"';
         }

         $page = 0;
@@ -435,9 +458,10 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
         }else{ // format as div sequence
             $i = 0;
             $close_pg = false;
+            $count_pg = ((int) $data['paginate'])? (count($files) / (int) $data['paginate']) : 1;
             foreach($files as $img){

-                if($data['paginate'] && ($i % $data['paginate'] == 0)){
+                if($data['paginate'] && ($count_pg > 1) && ($i % $data['paginate'] == 0)){
                      $ret .= '<div class="gallery_page gallery__'.$data['galid'].'" id="gallery__'.$data['galid'].'_'.(++$page).'">';
                      $close_pg = true;
                 }
@@ -450,7 +474,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {

                 $i++;

-                if($data['paginate'] && ($i % $data['paginate'] == 0)){
+                if($data['paginate'] && ($count_pg > 1) && ($i % $data['paginate'] == 0)){
                     $ret .= '</div>';
                     $close_pg = false;
                 }
@@ -527,7 +551,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {

         //prepare link attributes
         $a           = array();
-        $a['title']  = $this->_meta($img,'title');
+        $a['title']  = ($img['title'] == '')? $this->_meta($img,'title') : $img['title'];
         if($data['lightbox']){
             $href   = ml($img['id'],$dim_lightbox);
             $a['class'] = "lightbox JSnocheck";

Broken in Frusterick Manners

After upgrading gallery plugin would make dokuwiki unusable by inserting swipebox css into the page. Upon clicking any links you are presented with a huge black overlay over your browser window.

Tell the users where the images is used

Option to display a linklist, on which pages (of all pages namespaces or a special given namespace or a list of given namespaces ) the image is "used", i.e. included in the page for embedded display or as link. So that the visitor can go by the linklist to the pages where the image is used.

Maybe this list should be included just when I click on a picture so that it is displayed as single picture, and not on the real gallery display page ?!

//[[[email protected]|Rolf Hemmerling]] 2009-12-28 07:00//

Strange gallery behavior using arrow keys

Hi Guys,

I keep getting a strange error using the gallery plugin. If one browses the images using the arrow keys, the gallery suddenly jumps over images by itself. Also, it sometimes doesn't distinct between landscape and portrait format pictures any more.

I'm working with Dokuwiki Release 2012-01-25a "Angua" with the newest gallery version (updated today due to the issue). Of course, I cleared both browser and Dokuwiki cache before filing an issue here. My server runs on arch linux with nginx.

Here is a testing link for you: http://www.dkriesel.com/blog/2012/0701_ameise_gegen_wachsmottenlarve

On the client side, I was able to reproduce the errors on

  • Win 7 64bit with Firefox 13.0.1
  • Win 7 64bit with Opera 12

However, I think they are Javascript bugs.

Cheers
David

Toolbar button to create galleries

Hi, thank you for this great plugin. It works as expected so this is a feature request, what about adding a toolbar button to create galleries?

The whole syntax can be tedious to remember because the plugin has a lot of (interesting) options. Plus beginner users already have trouble using the basic syntax, let alone plugin syntax. The menu would only present checkboxes/text fields for each parameter - prefilled with the defaults - and an short explanation of what each parameter does.

The indexmenu plugin has that kind of menu - screenshot attached. It makes it really easy to use it without needing to remember the whole syntax, maybe there's some code to borrow there.

captur

Gallery overrides nocache in renderer

When caching is enabled in the gallery plugin, it overrides the current cache setting of the renderer. For example when you first put ~~NOCACHE~~ on a page and then the gallery plugin with default options, the page is cached again. This is especially annoying when the cache is disabled by another plugin on the page like the blog plugin that relies on the cache's being disabled for respecting ACLs.

I think the gallery plugin should only disable caching when requested but never enable caching.

Alternative text for Images on HTML tags

author     : Javier Espinosa Alfonso
email      : [email protected]
description: Gallery image plugin modified to enable edit alternative text of a image.
type       : syntax
lastupdate : 2009-08-18
compatible : 2008-05-05

Edit text alternative for an image in the gallery with HTML tags: a and img. Like this:
<img **alt="Text alternative"** src="image1.png">
<a **title="Title link"** href="go.html">Go</a>

Examples:

{{gallery>:namespace:?image_*.png&lightbox|All images with the same text alternative}}
{{gallery>:namespace:image_123.png|Alternative text without params}}
{{gallery>:namespace:image_123.png?&lightbox|Alternative text with params}}
{{gallery>::namespace:image_123.png}} // Default value
<?php
/**
 * Embed an image gallery
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <[email protected]>
 * @author     Joe Lapp <[email protected]>
 * @author     Dave Doyle <davedoyle.canadalawbook.ca>
 * @author     Javier Espinosa <[email protected] | blog.virunner.com/javier-espinosa/>(changes with @JEA)
 */

if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
require_once(DOKU_INC.'inc/search.php');
require_once(DOKU_INC.'inc/JpegMeta.php');

class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {

    /**
     * return some info
     */
    function getInfo(){
        return confToHash(dirname(__FILE__).'/info.txt');
    }

    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }

    /**
     * What about paragraphs?
     */
    function getPType(){
        return 'block';
    }

    /**
     * Where to sort in?
     */
    function getSort(){
        return 301;
    }


    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
        $this->Lexer->addSpecialPattern('\{\{gallery>[^}]*\}\}',$mode,'plugin_gallery');
    }

    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        global $ID;
        $match = substr($match,10,-2); //strip markup from start and end

        $data = array();

        $data['galid'] = substr(md5($match),0,4);

        // alignment
        $data['align'] = 0;
        if(substr($match,0,1) == ' ') $data['align'] += 1;
        if(substr($match,-1,1) == ' ') $data['align'] += 2;

// @JEA Begin
        // extract title
        list($match,$title) = explode('|',$match,2);
// @JEA End

        // extract params
        list($ns,$params) = explode('?',$match,2);
        $ns = trim($ns);

        // namespace (including resolving relatives)
        $data['ns'] = resolve_id(getNS($ID),$ns);

        // set the defaults
        $data['tw']       = $this->getConf('thumbnail_width');
        $data['th']       = $this->getConf('thumbnail_height');
        $data['iw']       = $this->getConf('image_width');
        $data['ih']       = $this->getConf('image_height');
        $data['cols']     = $this->getConf('cols');
        $data['filter']   = '';
        $data['lightbox'] = false;
        $data['direct']   = false;
        $data['showname'] = false;
        $data['showtitle'] = false;
        $data['reverse']  = false;
        $data['random']   = false;
        $data['cache']    = true;
        $data['crop']     = false;
        $data['sort']     = $this->getConf('sort');
        $data['limit']    = 0;
        $data['offset']   = 0;
        $data['paginate'] = 0;
// @JEA Begin
                // default value (can be changed)
        $data['title']    = 'No title';
        if (!empty($title)){
            $data['title'] = $title;
        }
// @JEA End

        // parse additional options
        $params = $this->getConf('options').','.$params;
        $params = preg_replace('/[,&\?]+/',' ',$params);
        $params = explode(' ',$params);
        foreach($params as $param){
            if($param === '') continue;
            if($param == 'titlesort'){
                $data['sort'] = 'title';
            }elseif($param == 'datesort'){
                $data['sort'] = 'date';
            }elseif($param == 'modsort'){
                $data['sort'] = 'mod';
            }elseif(preg_match('/^=(\d+)$/',$param,$match)){
                $data['limit'] = $match[1];
            }elseif(preg_match('/^\+(\d+)$/',$param,$match)){
                $data['offset'] = $match[1];
            }elseif(is_numeric($param)){
                $data['cols'] = (int) $param;
            }elseif(preg_match('/^~(\d+)$/',$param,$match)){
                $data['paginate'] = $match[1];
            }elseif(preg_match('/^(\d+)([xX])(\d+)$/',$param,$match)){
                if($match[2] == 'X'){
                    $data['iw'] = $match[1];
                    $data['ih'] = $match[3];
                }else{
                    $data['tw'] = $match[1];
                    $data['th'] = $match[3];
                }
            }elseif(strpos($param,'*') !== false){
                $param = preg_quote($param,'/');
                $param = '/^'.str_replace('\\*','.*?',$param).'$/';
                $data['filter'] = $param;
            }else{
                if(substr($param,0,2) == 'no'){
                    $data[substr($param,2)] = false;
                }else{
                    $data[$param] = true;
                }
            }
        }

        // implicit direct linking?
        if($data['lightbox']) $data['direct']   = true;


        return $data;
    }

    /**
     * Create output
     */
    function render($mode, &$R, $data) {
        if($mode != 'xhtml') return false;

        $R->info['cache'] = $data['cache'];
        $R->doc .= $this->_gallery($data);
        return true;
    }

    /**
     * Gather all photos matching the given criteria
     */
    function _findimages(&$data){
        global $conf;
        $files = array();

        $dir = utf8_encodeFN(str_replace(':','/',$data['ns']));

        // all possible images for the given namespace (or a single image)
        if(is_file($conf['mediadir'].'/'.$dir)){
            require_once(DOKU_INC.'inc/JpegMeta.php');
            $files[] = array(
                'id'    => $data['ns'],
                'isimg' => preg_match('/\.(jpe?g|gif|png)$/',$dir),
                'file'  => basename($dir),
                'mtime' => filemtime($conf['mediadir'].'/'.$dir),
                'meta'  => new JpegMeta($conf['mediadir'].'/'.$dir)
            );
            $data['_single'] = true;
        }else{
            search($files,$conf['mediadir'],'search_media',array(),$dir);
            $data['_single'] = false;
        }

        // done, yet?
        $len = count($files);
        if(!$len) return $files;
        if($data['single']) return $files;

        // filter images
        for($i=0; $i<$len; $i++){
            if(!$files[$i]['isimg']){
                unset($files[$i]); // this is faster, because RE was done before
            }elseif($data['filter']){
                if(!preg_match($data['filter'],noNS($files[$i]['id']))) unset($files[$i]);
            }
        }
        if($len<1) return $files;

        // random?
        if($data['random']){
            shuffle($files);
        }else{
            // sort?
            if($data['sort'] == 'date'){
                usort($files,array($this,'_datesort'));
            }elseif($data['sort'] == 'mod'){
                usort($files,array($this,'_modsort'));
            }elseif($data['sort'] == 'title'){
                usort($files,array($this,'_titlesort'));
            }

            // reverse?
            if($data['reverse']) $files = array_reverse($files);
        }

        // limits and offsets?
        if($data['offset']) $files = array_slice($files,$data['offset']);
        if($data['limit']) $files = array_slice($files,0,$data['limit']);

        return $files;
    }

    /**
     * usort callback to sort by file lastmodified time
     */
    function _modsort($a,$b){
        if($a['mtime'] < $b['mtime']) return -1;
        if($a['mtime'] > $b['mtime']) return 1;
        return strcmp($a['file'],$b['file']);
    }

    /**
     * usort callback to sort by EXIF date
     */
    function _datesort($a,$b){
        $da = $a['meta']->getDateField('EarliestTime');
        $db = $b['meta']->getDateField('EarliestTime');
        if($da < $db) return -1;
        if($da > $db) return 1;
        return strcmp($a['file'],$b['file']);
    }

    /**
     * usort callback to sort by EXIF title
     */
    function _titlesort($a,$b){
        $ta = $a['meta']->getField('Simple.Title');
        $tb = $b['meta']->getField('Simple.Title');
        return strcmp($ta,$tb);
    }


    /**
     * Does the gallery formatting
     */
    function _gallery($data){
        global $conf;
        global $lang;
        $ret = '';

        $files = $this->_findimages($data);

        //anything found?
        if(!count($files)){
            $ret .= '<div class="nothing">'.$lang['nothingfound'].'</div>';
            return $ret;
        }

        // prepare alignment
        $align = '';
        $xalign = '';
        if($data['align'] == 1){
            $align  = ' gallery_right';
            $xalign = ' align="right"';
        }
        if($data['align'] == 2){
            $align  = ' gallery_left';
            $xalign = ' align="left"';
        }
        if($data['align'] == 3){
            $align  = ' gallery_center';
            $xalign = ' align="center"';
        }
        if(!$data['_single']){
            if(!$align) $align = ' gallery_center'; // center galleries on default
            if(!$xalign) $xalign = ' align="center"';
        }

        $page = 0;

        // build gallery
        if($data['_single']){
            $ret .= $this->_image($files[0],$data);
            $ret .= $this->_showname($files[0],$data);
            $ret .= $this->_showtitle($files[0],$data);
        }elseif($data['cols'] > 0){ // format as table
            $close_pg = false;

            $i = 0;
            foreach($files as $img){

                // new page?
                if($data['paginate'] && ($i % $data['paginate'] == 0)){
                     $ret .= '<div class="gallery_page gallery__'.$data['galid'].'" id="gallery__'.$data['galid'].'_'.(++$page).'">';
                     $close_pg = true;
                }

                // new table?
                if($i == 0 || ($data['paginate'] && ($i % $data['paginate'] == 0))){
                    $ret .= '<table>';

                }

                // new row?
                if($i % $data['cols'] == 0){
                    $ret .= '<tr>';
                }

                // an image cell
                $ret .= '<td>';
                $ret .= $this->_image($img,$data);
                $ret .= $this->_showname($img,$data);
                $ret .= $this->_showtitle($img,$data);
                $ret .= '</td>';
                $i++;

                // done with this row? cloase it
                $close_tr = true;
                if($i % $data['cols'] == 0){
                    $ret .= '</tr>';
                    $close_tr = false;
                }

                // close current page and table
                if($data['paginate'] && ($i % $data['paginate'] == 0)){
                    if ($close_tr){
                        // add remaining empty cells
                        while($i % $data['cols']){
                            $ret .= '<td></td>';
                            $i++;
                        }
                        $ret .= '</tr>';
                    }
                    $ret .= '</table>';
                    $ret .= '</div>';
                    $close_pg = false;
                }

            }

            if ($close_tr){
                // add remaining empty cells
                while($i % $data['cols']){
                    $ret .= '<td></td>';
                    $i++;
                }
                $ret .= '</tr>';
            }

            if(!$data['paginate']){
                $ret .= '</table>';
            }elseif ($close_pg){
                $ret .= '</table>';
                $ret .= '</div>';
            }
        }else{ // format as div sequence
            $i = 0;
            $close_pg = false;
            foreach($files as $img){

                if($data['paginate'] && ($i % $data['paginate'] == 0)){
                     $ret .= '<div class="gallery_page gallery__'.$data['galid'].'" id="gallery__'.$data['galid'].'_'.(++$page).'">';
                     $close_pg = true;
                }

                $ret .= '<div>';
                $ret .= $this->_image($img,$data);
                $ret .= $this->_showname($img,$data);
                $ret .= $this->_showtitle($img,$data);
                $ret .= '</div> ';

                $i++;

                if($data['paginate'] && ($i % $data['paginate'] == 0)){
                    $ret .= '</div>';
                    $close_pg = false;
                }
            }

            if($close_pg) $ret .= '</div>';

            $ret .= '<br style="clear:both" />';
        }

        // pagination links
        $pgret = '';
        if($page){
            $pgret .= '<div class="gallery_pages">';
            for($j=1; $j<=$page; $j++){
                $pgret .= '<a href="#gallery__'.$data['galid'].'_'.$j.'" class="gallery_pgsel">'.$j.'</a> ';
            }
            $pgret .= '</div>';
        }

        return '<div class="gallery'.$align.'"'.$xalign.'>'.$pgret.$ret.'<div class="clearer"></div></div>';
    }

    /**
     * Defines how a thumbnail should look like
     */
    function _image($img,$data){
        global $ID;

        // calculate thumbnail size
        if($data['crop']){
            $w = $data['tw'];
            $h = $data['th'];
            $dim = array('w'=>$w,'h'=>$h);
        }else{
            $w = (int) $img['meta']->getField('File.Width');
            $h = (int) $img['meta']->getField('File.Height');
            $dim = array();
            if($w > $data['tw'] || $h > $data['th']){
                $ratio = $img['meta']->getResizeRatio($data['tw'],$data['th']);
                $w = floor($w * $ratio);
                $h = floor($h * $ratio);
                $dim = array('w'=>$w,'h'=>$h);
            }
        }

        //prepare img attributes
        $i             = array();
        $i['width']    = $w;
        $i['height']   = $h;
        $i['border']   = 0;
// @JEA Begin
//      $i['alt']      = $img['meta']->getField('Simple.Title');
        // alt attribute of <img>
        $i['alt']      = $data['title'];
// @JEA End
        $i['longdesc'] = trim(str_replace("\n",' ',$img['meta']->getField('Iptc.Caption')));
        if(!$i['longdesc']) unset($i['longdesc']);
        $i['class']    = 'tn';
        $iatt = buildAttributes($i);
        $src  = ml($img['id'],$dim);

        // prepare lightbox dimensions
        $w_lightbox = $img['meta']->getField('File.Width');
        $h_lightbox = $img['meta']->getField('File.Height');
        $dim_lightbox = array();
        if($w_lightbox > $data['iw'] || $h_lightbox > $data['ih']){
            $ratio = $img['meta']->getResizeRatio($data['iw'],$data['ih']);
            $w_lightbox = floor($w_lightbox * $ratio);
            $h_lightbox = floor($h_lightbox * $ratio);
            $dim_lightbox = array('w'=>$w_lightbox,'h'=>$h_lightbox);
        }

        //prepare link attributes
        $a           = array();
// @JEA Begin
//      $a['title']  = $img['meta']->getField('Simple.Title');
        // title attribute of <a>
        $a['title']  = $data['title'];
// @JEA End
        if($data['lightbox']){
            $href   = ml($img['id'],$dim_lightbox);
            $a['class'] = "lightbox JSnocheck";
            $a['rel']   = "lightbox";
        }else{
            $href   = ml($img['id'],array('id'=>$ID),$data['direct']);
        }
        $aatt = buildAttributes($a);

        // prepare output
        $ret  = '';
        $ret .= '<a href="'.$href.'" '.$aatt.'>';
        $ret .= '<img src="'.$src.'" '.$iatt.' />';
        $ret .= '</a>';
        return $ret;
    }


    /**
     * Defines how a filename + link should look
     */
    function _showname($img,$data){
        global $ID;

        if(!$data['showname'] ) { return ''; }

        //prepare link
        $lnk = ml($img['id'],array('id'=>$ID),false);

        // prepare output
        $ret  = '';
        $ret .= '<br /><a href="'.$lnk.'">';
        $ret .= hsc($img['file']);
        $ret .= '</a>';
        return $ret;
    }

    /**
     * Defines how title + link should look
     */
    function _showtitle($img,$data){
        global $ID;

        if(!$data['showtitle'] ) { return ''; }

        //prepare link
        $lnk = ml($img['id'],array('id'=>$ID),false);

        // prepare output
        $ret  = '';
        $ret .= '<br /><a href="'.$lnk.'">';
        $ret .= hsc($img['meta']->getField('Simple.Title'));
        $ret .= '</a>';
        return $ret;
    }
}

//Setup VIM: ex: et ts=4 enc=utf-8 :

wiki syntax interpretation on EXIF data

It would be nice to be able to use wiki links in the exif title and/or caption. E.g. such that the user can be point to the related page (could be a "blog" page) to find more info.

Not sure whether using exif data is the sane place to allow wiki syntax... Perhaps the "keywords" exif field could use some more functionality.

group images for lightbox viewer

Implement something like lightbox's 2 rel=lightbox[a_set] to group images. This might be useful for people using DW as blog engine (BlogTNG is quite cool) to separete photos from different posts.

"Nothing was found"

I am trying to use the gallery on my page with Flickr as the photo source. I get the response that Nothing was found when I save the page. I have read through all the instructions twice and have shortened the link so that it doesn't contain any question marks with the bit.ly service but there still seems to be this error. I have tested the gallery with media sourced within my wiki and this works fine. I have also tried inserting the feed links given in the configuration example except this doesn't work either.
Any help is much appreciated

Not sure if this is a real issue: showtitle does not work as expected

Environment: Latest public dokuwiki (Anteater). The gallery plugin is configured with "showname" and "showtitle".

Please see the screenshot at: http://img46.imageshack.us/i/galleryue.png/

As you can see in the screenshot's mediamanager, the first and second picture got some meta data ("lecker" and "auch lecker"). The thirdone has no meta data.

At top in the screenshot you can see gallery plugin in action. While the first two pictures are as expected (displaying filename + title => meta data), the thirdone has its filename displayed twice. I think that shouldn't be!?

I tought, that could be a default behavior (display filename if no meta data is available), but in other gallerys I use, I could not confirm this. When no meta data is available, then nothing is displayed - which makes sense ;-)

Additional: When I delete all meta data of this three pictures, the behave like the thirdone => displaying just the filename twice.

Regards

Casper

Vertical crop doesn't work with external images

When I use the crop parameter with local images it works as expected:

{{gallery>:?0&96x160&crop}}

However if I use it with external images the horizontal parameter behaves as expected, but the vertical parameter appears to be ignored.

{{gallery>http://www.23hq.com/rss/schabloni?0&96x160&crop}}

I'm using Weatherwax and the Gallery 2013-02-16.

Random image bug ?

On our homepage I have just added the display of a random image. There are about 50 images in all and they do not get updated.

{{gallery>:programmerguy?1&=1&random&400x300 }}

The problem is that when I force a page refresh (shift-refresh) the image will change a few times and then not refresh at all.

I know I could read through you PHP code, but I don't know PHP very well.
Is there something I don't know or am doing wrong ?

Link to Page that has the image Name

I am currently using the great gallery plugin together with the brand new dokutouch theme.
Because of this, I have all my images named after my pages (so they display nicely in the left dokutouch column).
It would be nice, if the gallery plugin could link to these pages.
For images that do not have a page equivalent (e.g. the dokuwiki-128.png) there could be no link. (or the direct link as a fallback)
Implemented as a new parameter ("page" instead of "direct" or so) this could be highly usable!!

I experimented a little bit:

Adding

 }elseif($data['page']) {
            $new_id = cleanID($data['ns'].':'.substr($a['title'], 0, -strlen(strrchr($a['title'], '.'))));
            $newpath = wikiFN($new_id);
            if ( @file_exists($newpath) ) {
              $href = "/doku.php/".$data['ns']."/".substr($a['title'], 0, -strlen(strrchr($a['title'], '.')));
            }else{
              $href   = ml($img['id'],array('id'=>$ID),$data['direct']);
            } 

In line 534 of syntax.php and adding "page" in metadata.php and setting $data['page'] = false (Around line 84) gives the result I wanted. This is of course not yet foolproof. But very nice already.

The code below acts even more sophisticated: if multiple images with different numbers at the end exist, all images link to the page. E.g.:
Page: Cake
Images: cake, cake2, cake3. The Numbers get cut off, all images link to the "Cake" page.

        }elseif($data['page']) {
            $sitename = substr($a['title'], 0, -strlen(strrchr($a['title'], '.')));
            $new_id = cleanID($data['ns'].':'.$sitename);
            $newpath = wikiFN($new_id);
            if ( @file_exists($newpath) ) {
              $href = "/doku.php/".$data['ns']."/".$sitename;
            }else{
              while (is_numeric(substr($sitename, -1))) {  //Remove all trailing numbers.
                $sitename = substr($sitename, 0, -1);  
              }
              $new_id = cleanID($data['ns'].':'.$sitename);
              $newpath = wikiFN($new_id);
              if ( @file_exists($newpath) ) {
                $href = "/doku.php/".$data['ns']."/".$sitename; 
              }else {
                $href   = ml($img['id'],array('id'=>$ID),$data['direct']);
              }
            }

feature request: allow more than one image argument

Currently, there is no way to show two or more specific images that do not match a simple pattern.
Suggestion:
Allow additional image arguments:
{{gallery>foobar.png?foobaz.png?goo*.jpg}}

---<)kaimartin(>---
(Thank you for this very useful plugin)

Syntax error messages with Ponder Stibbons 2014-05-05

Installed gallery plugin in a new installation of release 2014-05-05 "Ponder Stibbons". After every content edit, two "Strict Standards" warnings are displayed in the current page:

Strict Standards: Declaration of syntax_plugin_gallery::handle() should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /opt/wiki/labossiere/lib/plugins/gallery/syntax.php on line 17

Strict Standards: Declaration of syntax_plugin_gallery::render() should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /opt/wiki/labossiere/lib/plugins/gallery/syntax.php on line 17

Tried deleting the gallery plugin and re-installing, also updating to latest plugin version, but problem persists. There are no apparent errors, just the persistent warnings which appear on the page, which is annoying :-(

Wish: multiple galleries on one page

it is now possible to add multiple galleries on one page, but they are somehow combined when viewing them. When you open the first set of images in the lightbox it will continue with the next set (gallery) on the same page.

When you add special options like pagination, it can only be applied to one of the galleries on the page. If you add it to e.g. two galleries the second gallery will show the pagination buttons but iniatially no images.

Would like to see that like be able to add multiple galleries on one dokuwiki page as seperate galleries with each their own set of properties.

Sizing with direct parameter doesn't work

Setting a sized bounding box for the direct parameter seems to be ignored. The command I'm using is:

{{gallery>:?0&96x160&64X64&crop&direct}}

I do get linked directly to the image but the size doesn't seem to be honoured at all.

I'm using Weatherwax and Gallery 2013-02-16.

[BugFix] show single files

I've found a little but annoying mistake, that prevents from show single images -

{{gallery>:someimage.jpg }}

Workaround is:

{{gallery>:?someimage.jpg* }}

And the fix is following - in syntax.php, at line 256 change

if($data['single']) return $files;

to

if($data['_single']) return $files;

Click event on lightbox close button bubbles to underlying div on touch devices

On mobile / touch, the click event from the lightbox close button (the top-right corner X) bubbles down to thr underlying content, behind the lighbox div. If a button, or click-sensitive element happens to be below the X, lighbox overlay cannot be closed without "clicking" the underlying element with the same close click.

  • Happens on Chrome on Android, can be repro'd with Chrome debugger on Windows, with Touch emulation.
  • Reproducable on my dokuwiki sites (e.g. here), as well as two sites referenced on gallery plugin page 1, 2
  • Both Chrome debugger device modes Mobile and Desktop (touch) trigger the issue, whereas Mobile (no touch) or Desktop do not.

to repro:

-> browser lands at http://feeds2.feedburner.com/splitbrain

dw_lighbox_close_bubble

Lightbox mode broken

  • tested on Chrome and FF
  • dokuwiki version : weatherwax RC1
  • gallery version : 2013-02-16

The Lightbox mode is not working after upgrading from Adora to Weatherwax. Instead I get a direct link to this image.

The js.php file is loaded but the chrome console says "addInitEvent not defined".

I cleared the cache a dozen times.

Image Title character-limit

I am not sure if this is related to a limitation of Dokuwiki's EXIF functionality or the gallery plugin itself, but my image's EXIF titles seem to cut off (with ellipses "...") randomly between 60-something and 100-something characters.

This can be seen under thumbnails using "showtitle":

http://hypersweet.com/photos/2013/2013-05-23_australia_-_great_barrier_reef/home

As well as on an individual photo's detail page:

http://hypersweet.com/_detail/photos/2013/2013-05-23_australia_-_great_barrier_reef/img_1707.jpg?id=photos%3A2013%3A2013-05-23_australia_-_great_barrier_reef%3Ahome

Is this limit hard-coded somewhere in the code? If so I would be very grateful if this could be made an adjustable option in the settings, or at the very least I'd like to know where this number is set so I could increase it to something allowing longer descriptions, like 512 characters or more.

Pagination is broken in gallery 2016-01-24

Tested with a folder of 20 images, gallery in <table> mode (plugin»gallery»cols = 5). When pagination is activated there are huge bugs. Every images in the folder are displayed and some are left out of the <table>. When the pagination is set to 5 or 10 it works.

{{gallery>:photos?~10}} works
{{gallery>:photos?~8}} does not work

On the other hand, one paginated gallery in <div> mode (plugin»gallery»cols = 0) works fine. But when inserting 2 paginated galleries on a page, the thumbnails of the last one are hidden but not the pagination links. And when a pagination link is clicked, the thumbnails appear.

Can you fix this, it's frustrating !
Thank you.


DokuWiki version : 2015-08-10 Detritus
Gallery plugin version : 2016-01-24
Default dokuwiki template

Lightbox not working on Weatherwax RC1

Latest version of gallery plugin installed on upgraded dokuwiki to Weatherwax RC1. Everything seems to work except the lightbox option. Clicking on a image with lightbox option active gives the full screen image instead of the usual overlay.

Bug?: Cannot purge cache of gallery thumbnail images

My page has {{gallery>:img.jpg}}. I replaced data/media/img.jpg with a different image on disk (not through web upload).
I can't get the small gallery thumbnail image to show the new image. It seems to always read the old one from cache. The big lightbox popup image does show the updated image.

I tried the following to purge the cache:

  1. ?purge=true on the page url containing the {{gallery}}
  2. adding &nocache to the gallery call: {{gallery>:img.jpg?nocache}}
  3. disabling cache in gallery by unchecking cache in the admin gallery settings
  4. adding ~~~NOCACHE~~~ to the page
  5. adding purge=true to the actual small image url (right-click show image) HOST/_media/img.jpg?w=200&h=200&tok=1ede80&purge=true

For all cases, I made sure the image is not coming from browser cache, by hard-refreshing page (plus having browser cache disabled).

I'm using Release 2017-02-19e "Frusterick Manners" and the latest version of the Gallery plugin

gallery overview mode

I would like a gallery mode that (like pglist plugin) does a nice list of all pages in the given namespace that include a {{gallery}}-tag, maybe even with a random preview picture. I could be used in gallery-overview page to show all existing gallerys

Use CSS max-width and max-height instead of attributes on images

I think it would make more sense to use CSS to define the size of the picture instead of html attributes.
Example :

<img src="picture.jpg" style="max-width: 120px; max-height: 120px;"/>

Instead of

<img src="picture.jpg" width="120" height="120" border="0"/>

I might create a pull request for this in the near future.

moveable Lightbox

Hi, any chances that the lightbox that pops up could either be made moveable while holding the left mouse button, or in the config you could tell it to open somewhere else ie. bottom, bottom-left etc...

Left align not working

I can use right and center align for my images, but setting all images as left align don't work as expected. With this I'm expecting that all images stays in the same line:

{{gallery>:compartilhados:1.svn.png?200&lightbox }} {{gallery>:compartilhados:2.svn.png?200&lightbox }} 
{{gallery>:compartilhados:3.svn.png?200&lightbox }} {{gallery>:compartilhados:4.svn.png?200&lightbox }}

This kind of alignment works with the default image of Doku. Maybe something changed in the latest version? I'm using: 2013-12-08 "Binky"

warning Missing argument 1 for SimplePie_File::SimplePie_File(),

Hi,

I' get this error if I use picassa (feed) as source

Warning: Missing argument 1 for SimplePie_File::SimplePie_File(), called in /homepages.../www/inc/FeedParser.php on line 52 and defined in /homepages/.../www/inc/SimplePie.php on line 7650

Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /homepages/.../www/inc/SimplePie.php on line 7858

Important. the page has to be uncached ( or use ..?purge=true)

code

{{gallery>https://picasaweb.google.com/data/feed/base/user/...xxx.../albumid/...xxx...}}

Lightbox's strange behaviour

Until now, the lightbox function was working really well. Nothing to say, on the contrary!

However, due to another issue, I had to delete and re-install all my media file. Since then, the lightbox mode only works normally in the "Modify this page" of my articles, when i preview what has been written (when I click on the image, it appears normally). But in the article itself, when I click on the image, the back screen is deemed as usual but the image itself appears at the very bottom of the screan, usually partially hidden as it is too far at the bottom. Worse, the more images I have in the gallery, the lower it is published. It is kind of proportionate. With > 4 pictures, the images cannot be seen any more.

I tried uninstalling and re-installing the plugin and checking the script.js, which is all as it should be.

What is this due to?

add a "Modern" Modal Box

Any way to replace this out-dated Lightbox clone by a "modern" overlay modal box ;-) many thanks in advance --- Pamela 2011/07/18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.