Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Thumbnails in a different directory  (Read 8363 times)

0 Members and 1 Guest are viewing this topic.

Intrus

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Thumbnails in a different directory
« on: March 26, 2005, 08:14:41 pm »

What i want is that the thumbnails are generated in another folder than the original picture:

For a pic in "<CPG_Root>/albums/folder_name/some_image.jpg"
to be created in, let's say: "<CPG_Root>/thumbnails/folder_name/thumb_some_image.jpg"

The reason of this is that i have 2 comp, an old one (FreeBSD server, i will name it: F) hosting all services: apache, mysql, etc.
And my main computer for data storage and general use (regular windows, i will name it W).

I don't want thumbnails to be created on W because i sometime view those pictures from W and storing all the pictures on F is not an option since it doesn't have that much diskspace (thumbnails are ok with size of 80px max and compression of 35 i get around 10KB-15KB per picture)

What i'm currently doing is sharing folders on W with read only rights and F mount them in a dedicated place named "<somewhere>/samba/<other_folders>" and i put a symlink in "<CPG_Root>/albums/" to "<somewhere>/samba/" so i can add pictures from the samba folder but i need the thumbnails to be generated somewhere else.

I've searched the forum but didn't find what i wanted (or i haven't well searched -_-) (the FAQ "custom thumnails" isn't what i need)

So i've done some quick (and probabldy dirty) hack (that work) on those files:

in file addpic.php
toward the beggining
Code: [Select]
<...>
$pic_file = base64_decode($HTTP_GET_VARS['pic_file']);
$dir_name = dirname($pic_file) . "/";
$file_name = basename($pic_file);

// we create other directory that will follow the same structure than the album of original pictures
$dir_check = "thumbnails/albums/" . dirname($pic_file) . "/";

$dir_explode = explode("/", $dir_check);
$new_dir = "./";
foreach($dir_explode as $part_dir)
{
$new_dir = $new_dir . $part_dir ;
if(!is_dir($new_dir))
{
mkdir ($new_dir, 0744);
}
$new_dir = $new_dir . "/";
}
// end of additional lines
<...>

in file "picmgmt.inc.php"
function resize_image
Code: [Select]
<...>

function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
{
    global $CONFIG, $ERROR;
    global $lang_errors;

$dest_file = "thumbnails/" . $dest_file; // Changing the destination so it goes in our folder

<...>

and

Code: [Select]
<...>

        case "im" :
            if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
                // get the basedir, remove '/include'
                $cur_dir = substr(dirname(__FILE__), 0, -8);
                $src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
                $im_dest_file = str_replace('%', '%%', ('"thumbnails\\' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"')); // added the wanted destination folder, haven't run in it yet, but it's just a hunch
            } else {
                $src_file = escapeshellarg($src_file);
                $im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
            }

<...>

in file "function.inc.php"
function display_thumbnails
Code: [Select]
<...>
        if (count($pic_data) > 0) {
                foreach ($pic_data as $key => $row) {
                        $i++;

                        $pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);

                        $pic_url = "thumbnails/" . get_pic_url($row, 'thumb');    // added the wanted destination folder
                        if (!is_image($row['filename'])) {
<...>

function "display_film_strip"
Code: [Select]
<...>
        if (count($pic_data) > 0) {
                foreach ($pic_data as $key => $row) {
                        $hi =(($pos==($i + $lower_limit)) ? '1': '');
                        $i++;

                        $pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);

                        $pic_url = "thumbnails/" . get_pic_url($row, 'thumb');       // added the wanted destination folder
                        if (!is_image($row['filename'])) {
                                $image_info = getimagesize($pic_url);
<...>

in file "index.php"
function list_albums
Code: [Select]
<...>
            if ($count > 0) {
                if ($alb_thumb['filename']) {
                    $picture = &$alb_thumb;
                } else {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight ".
                           "FROM {$CONFIG['TABLE_PICTURES']} ".
                           "WHERE pid='{$alb_stat['last_pid']}'";
                    $result = db_query($sql);
                    $picture = mysql_fetch_array($result);
                    mysql_free_result($result);
                }
                $pic_url = "thumbnails/". get_pic_url($picture, 'thumb'); // added the wanted destination folder
                if (!is_image($picture['filename'])) {
                        $image_info = getimagesize($pic_url);
<...>

in file "editpics.php"
function form_pic_info
Code: [Select]
<...>
        if (UPLOAD_APPROVAL_MODE) {
                // Commented out by Omni; Duplicate of above
                //$pic_info = $CURRENT_PIC['pwidth'].' &times; '.$CURRENT_PIC['pheight'].' - '.($CURRENT_PIC['filesize'] >> 10).$lang_byte_units[1];
                if($CURRENT_PIC['owner_name']){
                        $pic_info .= ' - <a href ="profile.php?uid='.$CURRENT_PIC['owner_id'].'" target="_blank">'.$CURRENT_PIC['owner_name'].'</a>';
                }
        }

        $thumb_url = "thumbnails/" . get_pic_url($CURRENT_PIC, 'thumb');    // added the wanted destination folder
        $thumb_link = 'displayimage.php?&pos='.(-$CURRENT_PIC['pid']);
        $filename = htmlspecialchars($CURRENT_PIC['filename']);
<...>

in file "delete.php"
function delete_picture
Code: [Select]

    $aid = $pic['aid'];
    $dir = $CONFIG['fullpath'] . $pic['filepath'];
    $dir_thumb = "thumbnails/" . $CONFIG['fullpath'] . $pic['filepath'];   // Our thumbnail is in another directory
    $file = $pic['filename'];


    if (!is_writable($dir)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['directory_ro'], htmlspecialchars($dir)), __FILE__, __LINE__);

    echo "<td class=\"tableb\">" . htmlspecialchars($file) . "</td>";

    $files = array($dir . $file, $dir . $CONFIG['normal_pfx'] . $file, [b]$dir_thumb [/b]. $CONFIG['thumb_pfx'] . $file);   // and we put it in the list
    foreach ($files as $currFile) {
        echo "<td class=\"tableb\" align=\"center\">";
        if (is_file($currFile)) {


I haven't tested the functions in other modes; but for what i need, it works, no change of the databse structure, nor major change of the core. It could be easily (i think) implemented if other people find some use of it, otherwise, i'll just do change myself on future version for personal use. <_<
(and i hope i haven't forgot to mention other modification i have made...)

I thought i could change the "get_pic_url", but it behave in a weird way, like showing the full pic and not the thumbnail, or showing thumbnail and not the full pic... Maybe i'll dig in some more if i have some spare time...
« Last Edit: March 26, 2005, 08:47:38 pm by Intrus »
Logged

Intrus

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Thumbnails in a different directory
« Reply #1 on: March 27, 2005, 12:19:39 am »

Hum, i should read better the code, only need to change:
./addpic.php
./delete.php
./include/picmgmt.inc.php
./include/function.inc.php

in function.inc.php, only change get_pic_url

by adding/changing in the function
Code: [Select]
if ( $mode == "thumb" )
{
$thumb_path = "thumbnails/";
}

        return $thumb_path . $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);


it give a lot less modifications to do and less problem -_-
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Thumbnails in a different directory
« Reply #2 on: March 28, 2005, 08:09:09 pm »

Are you contributing this as a hack? If so, we can move accordingly.

Or is this a feature request? I'm not sure of the benefit of this for many other users since this would increase the number of folders in their accounts. However, I'm sure there are those who would appreciate this as a hack.
Logged

Intrus

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Thumbnails in a different directory
« Reply #3 on: March 29, 2005, 05:08:58 am »

Well, i thought it could be implemented as an option in CPG, so if someone needed this feature, they just need to fill in the form in the configuration menu.

But if you feel like it should be in the hack section, please do so.
Logged

eris667

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 47
    • http://www.strm.us/cpg15x/index.php
Re: Thumbnails in a different directory
« Reply #4 on: July 06, 2011, 12:19:27 am »

I was just wondering if anyone could verify if this is working in CPG1.5x?
I know the post is old, but this is exactly what I would like to do when I upgrade from 1.4 to 1.5
(Unless this can be accomplished in a better way now. . .)

Thank You !

Mike
http://www.strm.us/cpg14x/index.php
http://forum.coppermine-gallery.net/index.php/topic,73047.0.html

giancarlo64

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Thumbnails in a different directory
« Reply #5 on: October 14, 2011, 07:27:00 am »

Hi,
this would be a very interesting feature for the gallery. It permit to decide where to have the full size pictures and the thumbnails.
In my case I already have about 190Gb of images saved on the server. They are already sorted in folders.I used symlink to redirect the album folder to my server picture folder.
But I don't want this pictures and/or folders to be modified by other programs. So I don't want that the thumbnails will be generated on the same folders.
Allowing to choose the thumbnails and middle format folder would be a very good feature.
Will be this feature implemented?

Regard

Gian Carlo
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Thumbnails in a different directory
« Reply #6 on: October 14, 2011, 01:13:11 pm »

We cannot implement this feature in the cpg1.5.x stage, so if it will be implemented it will take some time until the next major version will be released.
Logged
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 19 queries.