Galleries Listing + Preview Thumbnails
  • Hi all.

    Started using Minishowcase this year. Its Great. Thanks Victor.

    Have looked through forums and cant find this anywhere, and thought i would share.

    My Co-worker and myself have been playing around and thought it would be handy to have thumbnails for galleries, rather than a drop down, or a basic text listing. This was done by editing "ajax.functions.js"

    It looks Great, and used the thumnails that are cached by Minishowcase. Its written to use the first file in a set. I have used "001.jpg" as my default. Im sure there is a way to get the thumbnails dynamically, but im still learning, and this was tough enough for me.

    Enjoy, Michael

    This is the Code we have added to the "Check Galleries" heading

    //// check galleries //////////////////////////////////////////////

    function setGalleries()
    {
    cp.call( base_url+'libraries/ajax.gateway.php',
    'get_galleries',
    updateGalleries );

    var html = ' '
    +lang['loading_menu']
    +'...';

    if (use_select_menu) {
    innerhtml('galleries_select', html);
    } else {
    innerhtml('galleries_menu', html);
    }
    }

    function updateGalleries(request)
    {
    if (use_select_menu) {
    updateGalleriesSelect(request);

    } else {
    updateGalleriesMenu(request);
    }
    }


    function updateGalleriesMenu(request)
    {
    var result = getEncoded(request,'enc');

    if (result != "null") {
    var galleries = result.split("|");
    var selected = null;
    var menu = "";
    var gallery_list = new Array();

    var ul = document.createElement('ul')

    for (var i=0; i0) li.setAttribute('class', 'topline')

    if (number_galleries) {
    var em = document.createElement('em')
    em.innerHTML = zero(i+1)+' '
    li.appendChild(em)
    }

    var a = document.createElement('a')
    a.setAttribute('id', id)
    a.setAttribute('href', 'javascript:;')
    if (!number_galleries) a.setAttribute('class', 'nonum')
    a.onclick = function() { setGallery(this.id.sq(),this) }
    a.innerHTML = '' + imageName(galleryName(id))
    +' ('+g_id_files+')'
    li.appendChild(a)

    ul.appendChild(li)
    }
    SU
    innerhtml('galleries_menu', '');

    var m = getID('galleries_menu')
    m.appendChild(ul)

    if (query_parameters['g']) {
    setGallery(query_parameters['g'], false);

    } else if (g_default) {
    if ((g_default_name != '') && (g_default_name_exists)) {
    setGallery(g_default_name, false);
    } else {
    for (i=0; i
  • Perfect this is exactly what I was looking for :)

    I've attached the ajax.functions, I believe I got everything correct in it. I"m trying to work on the thumbnails to make them display. One error in your code, is line 171, the SU command is not recongized. By removing the SU it appears to work.
  • Yeah, to have it dynamically grab the thumbnails, and not having to rename all of your files. this would be great .Glad you liked the idea !
  • Hey, could you show me how this hack does look like?
    greetz
  • This is great, thanks for posting it!

    After incorporating, I found that it was working with some galleries but not others. I've only done a little testing, but it looks like ordered galleries (that is, ones with names beginning nn-) aren't working with this mod.
  • Yeah, it isn't picking up on the numbers before the gallery name. If I create a cache directory without the numbers & hyphen and put th_001.jpg in it, it pulls up the image in the menu. Still not sure why yet. I'm slow.
  • Actually... doing a "ln -s cache_03-GalleryName cache_GalleryName" works too.

    The problem also occurs when the gallery name starts with a number, not just with "nn-" gallery names. My gallery called "40_Market_St" doesn't show a gallery thumbnail unless I create /cache/cache_Market_St/th_001.jpg -- it's dropping the number and underscore.
  • I'd love to see this script in action. I think it's what I've been looking for but can't tell until I see it at work. If someone can point me in the direction of a gallery that's using it I'd really appreciate it. Thanks.

    Don
  • Anyone there?
  • [quote=neuromonkey][/quote]
    anyone? this not working if gallery's name start with nn- :(
  • my version part1

    in config/settings.php
    add
    $settings['show_menu_image'] = true;

    in libraries/ajax.init.js
    add
    var show_menu_image = ;

    in libraries/ajax.gateway.php

    after

    case "image":
    $return_value = get_image($g_num, $g_img, $g_name);
    break;

    add

    case "imgmenu":
    $return_value = create_menu_image($g_id);
    break;


    after

    $cp->register('get_image');

    add
    $cp->register('create_menu_image');

    and add function

    function create_menu_image($_id)
    {

    global $settings;
    global $base_path;

    $_double = $settings['set_double_encoding'];

    $id = ($_double) ? Url_decode($_id) : rawurldecode($_id);

    $info = "null";

    $th_dir = "$base_path/cache/".$settings['gallery_prefix'].$id;

    if ($dh = opendir("$th_dir")) {

    // iterate over file list & print filenames
    while (($filename = readdir($dh)) !== false) {
    if ((strpos($filename,".") !== 0)
    && (strpos($filename,"_") !== 0)
    && (!is_file("$base_path/galleries/$filename"))
    ) {
    $galleries[] = $filename;
    $mumenuimg=$galleries[1];
    }
    }
    // close directory
    closedir($dh);

    }
    copy($th_dir.'/'.$mumenuimg, $th_dir.'/th_first.jpg') ;
    }
  • part 2
    in libraries/ajax.functions.js
    chenge function updateGalleriesMenu

    ......
    if (number_galleries) {
    var em = document.createElement('em')
    em.innerHTML = zero(i+1)+' '
    li.appendChild(em)
    }

    if (show_menu_image) {
    var img_dir_name = base_url+ 'images/';
    var menu_img = 'nofoto.gif';

    var req;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    req = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
    req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    req.open('GET', 'cache/cache_'+id+'/th_first.jpg', false);
    req.send(null);

    if (req.status == 200) {
    img_dir_name = base_url+ 'cache/' + gallery_prefix
    +setUrlEncoding(active_id)+id+ '/';
    menu_img = thumbnail_prefix + 'first.jpg';
    } else {
    img_dir_name = base_url+ 'images/';
    menu_img = "nofoto2.gif";
    cp.call(base_url+'libraries/ajax.gateway.php', 'get_menu_image', '' , Url.encode(id));
    }

    menu_img_url = '

    '

    }

    var a = document.createElement('a')
    a.setAttribute('id', id)
    a.setAttribute('href', 'javascript:;')
    if (!number_galleries) a.setAttribute('class', 'nonum')
    a.onclick = function() { setGallery(this.id.sq(),this) }
    a.innerHTML = menu_img_url+imageName(galleryName(id))
    +' ('+g_id_files+')'
    li.appendChild(a)

    ......
  • sorry change in last post

    cp.call(base_url+'libraries/ajax.gateway.php', 'get_menu_image', '' , Url.encode(id));

    to
    cp.call(base_url+'libraries/ajax.gateway.php', 'create_menu_image', '' , Url.encode(id));

In this Discussion