How using smaller thumbs for the filmstrip? How using smaller thumbs for the filmstrip?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How using smaller thumbs for the filmstrip?

Started by Cyclist, December 01, 2005, 12:39:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cyclist

As I am in progess of adapting the themes to my needs I discovered another problem which I can't solve by myself. I included the filmstrip into my theme which is based on the classic theme. All thumbs of my site have the same size. I would like to use smaller thumbs for the filmstrip. Is there a way to set the thumbs used for the filmstrip to a smaller size (e.g. max. height/width 65 px)? I coulnd't find a solutuion on the forum search. But maybe I missed something.

donnoman

Put this in your theme.php


function theme_display_film_strip(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $pos, $sort_options, $mode = 'thumb')
{
    global $CONFIG, $THEME_DIR;
    global $template_film_strip, $lang_film_strip;

    static $template = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $spacer = '';

    if ((!$template)) {
        $template = $template_film_strip;
        $thumb_cell = template_extract_block($template, 'thumb_cell');
        $empty_cell = template_extract_block($template, 'empty_cell');
    }

    $cat_link = is_numeric($aid) ? '' : '&cat=' . $cat;

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['max_film_strip_items']) . '%';

    $i = 0;
    $thumb_strip = '';
    foreach($thumb_list as $thumb) {
        //modify $new_size for max dimension of thumbnails in filmstrip
        $new_size = 65;
        preg_match('/(?<=width=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        $srcWidth=$matches[0][0];
        preg_match('/(?<=height=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        $srcHeight=$matches[0][0];
        $ratio = max($srcWidth, $srcHeight) / $new_size;
        $ratio = max($ratio, 1.0);
        $destWidth = (int)($srcWidth / $ratio);
        $destHeight = (int)($srcHeight / $ratio);
        $thumb['image']=preg_replace('/width="[^"]*"/','width="'.$destWidth.'"',$thumb['image']);
        $thumb['image']=preg_replace('/height="[^"]*"/','height="'.$destHeight.'"',$thumb['image']);
        $i++;
        if ($mode == 'thumb') {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => '',
                '{ADMIN_MENU}' => ''
                );
        }
        $thumb_strip .= template_eval($thumb_cell, $params);
    }

    if (defined('THEME_HAS_FILM_STRIP_GRAPHICS')) {
        $tile1 = $THEME_DIR . 'images/tile1.gif';
        $tile2 = $THEME_DIR . 'images/tile2.gif';
    } elseif (defined('THEME_HAS_FILM_STRIP_GRAPHIC')) {
        $tile1=$tile2=$THEME_DIR . 'images/tile.gif';
    } else {
        $tile1=$tile2= 'images/tile.gif';
    }

    $params = array('{THUMB_STRIP}' => $thumb_strip,
        '{COLS}' => $i,
        '{TILE1}' => $tile1,
        '{TILE2}' => $tile2,
        );

    ob_start();
    starttable($CONFIG['picture_table_width']);
    echo template_eval($template, $params);
    endtable();
    $film_strip = ob_get_contents();
    ob_end_clean();

    return $film_strip;
}

Cyclist

Thanks donnoman. That works very well for me!

wieland


jonplqs

Thanks for the code its works.... I have a question. Can i put two rows in the film strip ?

Joachim Müller



Joachim Müller

This thread explains how to have smaller thumbs in filmstrip. Only questions that directly relate are allowed. Putting two rows into the film strip is an entirely different animal. Therefor, your question doesn't belong here (just because the thread deals with "filmstrip"). It should go into a new thread.

Imagine a driving instructor giving a tutorial on truck driving. All his pupils are wannabe-truck drivers who want to hear about truck driving. They came from far away to learn how to drive a truck. Then suddenly someone turns up and says: "you're a driving instructor, teach me how to drive a bike". Do you think the driving instructor would be willing to do so? Do you think the audience (remember, they came specifically to learn about truck driving) would like the driving instructor to drift away from the original thread and explain something completely else during the "truck driving lesson"? Of course you wouldn't expect nor want this to happen. The driving instructor would instead say "come later, when the truck driving lessons are over and the others won't be kept waiting. I'll teach you how to drive a bike then."

Did you like my little story? In real life, everybody agrees that it's common sense not to interfere with something completely unrelated, yet in the world of computers (and particularly on forums, mailing lists etc.) people like to think that it's OK not to use common sense and butt in with their unrelated questions.
This is not individual support, where you could jump from one topic to another. We don't do individual support. We believe in this forum as a sort of "knowledge repository" on everything related to coppermine. You need discipline - that's why board rules exist (to remind people of the rules that are needed to keep this forum intact and functional). People who misbehave are told so, yet we expect them to look up what they did wrong after having been told so.

Bottom line: butt out of this thread. Start a new one instead, providing as much detail as possible.

Joachim