Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Customizing the thumbnails based on theme  (Read 8523 times)

0 Members and 1 Guest are viewing this topic.

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Customizing the thumbnails based on theme
« on: December 15, 2013, 08:26:27 am »

Is there a way that I can add to the theme.php a link to a nopic thumbnail so I don't have to change it every update?

http://www.solidsnakelegacy.net/gallery
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #1 on: December 16, 2013, 06:38:12 am »

I copied this code from the functions.inc file into my theme.php file, and added the thumb location, got no errors adding it, but the thumb doesn't show up.  Is there a way I can get this to work?

Code: [Select]
        // Use default thumbs
        if (is_null($filepathname)) {

            // Check for default theme- and global-level thumbs
            $thumb_paths[] = $THEME_DIR.'images/';                 // Used for custom theme thumbs
            $thumb_paths[] = 'images/thumbs/';                     // Default Coppermine thumbs

            foreach ($thumb_paths as $default_thumb_path) {
                if (is_dir($default_thumb_path)) {
                    if (!$system_pic) {
                        foreach ($thumb_extensions as $extension) {
                            // Check for extension-specific thumbs
                            if (file_exists($default_thumb_path . $CONFIG['thumb_pfx'] . $mime_content['extension'] . $extension)) {
                                $filepathname = $default_thumb_path . $CONFIG['thumb_pfx'] . $mime_content['extension'] . $extension;
                                //thumb cropping - if we display a system thumb we calculate the dimension by any and not ex
                                $pic_row['system_icon'] = true;
                                break 2;
                            }
                        }
                        foreach ($thumb_extensions as $extension) {
                            // Check for media-specific thumbs (movie,document,audio)
                            if (file_exists($default_thumb_path . $CONFIG['thumb_pfx'] . $mime_content['content'] . $extension)) {
                                $filepathname = $default_thumb_path . $CONFIG['thumb_pfx'] . $mime_content['content'] . $extension;
                                //thumb cropping
                                $pic_row['system_icon'] = true;
                                break 2;
                            }
                        }
                    } else {
                        // Check for file-specific thumbs for system files
                        foreach ($thumb_extensions as $extension) {
                            if (file_exists($default_thumb_path . $CONFIG['thumb_pfx'] . $file_base_name . $extension)) {
                                $filepathname = $default_thumb_path . $CONFIG['thumb_pfx'] . $file_base_name . $extension;
                                //thumb cropping
                                $pic_row['system_icon'] = true;
                                break 2;
                            }
                        } // foreach $thumb_extensions
                    } // else $system_pic
                } // if is_dir($default_thumb_path)
            } // foreach $thumbpaths
        } // if is_null($filepathname)

        if ($filepathname) {
            $filepathname = path2url($filepathname);
        }
    }

    if (is_null($filepathname)) {

        $localpath = $pic_row['filepath'] . $pic_prefix[$mode] . $pic_row['filename'];

        // Check here that the filename we are going to return exists
        // If it doesn't exist we return a placeholder image
        // We then log the missing file for the admin's attention
        if (file_exists($url_prefix[$pic_row['url_prefix']] . $localpath)) {
            $filepathname = $url_prefix[$pic_row['url_prefix']] . path2url($localpath);
        } else {
            $filepathname = 'http://www.solidsnakelegacy.net/images/content/whole/thumbs/thumbs_nopic.jpg';
            $pic_row['system_icon'] = true;
            if ($CONFIG['log_mode'] != 0) {
                log_write("File {$url_prefix[$pic_row['url_prefix']]}$localpath is missing.");
            }
        }
    }
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Changing nopic thumb
« Reply #2 on: December 16, 2013, 01:31:06 pm »

Sorry for the double post of this.  I don't think I explained what I wanted in the other topic.

I would like to change the nopic to a custom one, but tie it with my theme so that I don't have to change the file everytime there is an update

http://www.solidsnakelegacy.net/gallery
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #3 on: December 16, 2013, 01:38:56 pm »

There are 4 possibilities to use a custom thumb_nopic.jpg file:
1. Replace the file in thumbs/ (after each update) or just don't overwrite it while updating your gallery
2. Adjust the path in include/functions.inc.php (after each update)
3. Create a plugin which changes the path to your needs (use plugin filter "picture_url")
4. Find all theme functions where thumb_nopic.jpg may occur and manipulate the path at several places (not recommended)

I suggest option 3.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Changing nopic thumb
« Reply #4 on: December 16, 2013, 01:40:52 pm »

Sorry for the double post of this.  I don't think I explained what I wanted in the other topic.
Merged your two threads. Please don't double post. Instead, reply to your own related threads.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #5 on: December 16, 2013, 02:30:50 pm »

again sorry for the double post.  I just wasn't sure if my first topic explained it enough.

By theme functions do you mean altering what {THUMB} displays?  How would I do that?  I know its adding if, and else conditionals, but I don't know where to put them.  Sorry still a bit of a php novice.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #6 on: December 16, 2013, 02:44:18 pm »

I don't know why you've chosen the worst solution. As I already said, you probably need to add code at several places. I haven't checked where exactly you need to add it and also won't do that for you, as I already provided 3 other solutions.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #7 on: December 17, 2013, 07:32:47 am »

I wasn't really gonna go with option 4.  I was just clarifying that by theme function if you meant the {THUMB} code from theme.php

I tried editing the include/functions.inc.php file, but it doesn't change the nopic.

here is the code from the file:

Code: [Select]

    if (is_null($filepathname)) {

        $localpath = $pic_row['filepath'] . $pic_prefix[$mode] . $pic_row['filename'];

        // Check here that the filename we are going to return exists
        // If it doesn't exist we return a placeholder image
        // We then log the missing file for the admin's attention
        if (file_exists($url_prefix[$pic_row['url_prefix']] . $localpath)) {
            $filepathname = $url_prefix[$pic_row['url_prefix']] . path2url($localpath);
        } else {
            $filepathname = 'http://www.solidsnakelegacy.net/images/content/whole/thumbs/thumb_nopic.jpg';
            $pic_row['system_icon'] = true;
            if ($CONFIG['log_mode'] != 0) {
                log_write("File {$url_prefix[$pic_row['url_prefix']]}$localpath is missing.");
            }
        }
    }

    // Added hack:  "&& !isset($pic_row['mode'])" thumb_data filter isn't executed for the fullsize image
    if ($mode == 'thumb' && !isset($pic_row['mode'])) {
        $pic_row['url']  = $filepathname;
        $pic_row['mode'] = $mode;

        $pic_row = CPGPluginAPI::filter('thumb_data', $pic_row);
    } elseif ($mode != 'thumb') {
        $pic_row['url']  = $filepathname;
        $pic_row['mode'] = $mode;
    } else {
        $pic_row['url'] = $filepathname;
    }

    $pic_row = CPGPluginAPI::filter('picture_url', $pic_row);

    return $pic_row['url'];
} // function get_pic_url



I don't know if this would would work, but if I added something like this to the theme.php file, could this work:

Code: [Select]
if $pic_thumb_url = images/thumbs/thumb_nopic.png
replace with = http://www.solidsnakelegacy.net/images/content/whole/thumbs/thumb_nopic.jpg

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #8 on: December 17, 2013, 09:17:04 am »

How the theme engine works.

This means that code you "just add" to theme.php affects nothing (as you already found out). If you still want to use theme.php, you need to find out in which functions the placeholder image might be used.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #9 on: December 17, 2013, 09:23:45 am »

Alrighty, thanks for the info about the theme functions.

But what about the functions.inc file?  I added the change to it, uploaded it, and it still had no effect.  Double checked the save, and saw the url was input correctly.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #10 on: December 17, 2013, 09:27:38 am »

Please attach your include/functions.inc.php file as zip file to your next reply.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #11 on: December 17, 2013, 09:33:08 am »

Sure, here it is

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #12 on: December 17, 2013, 10:05:12 am »

Works for me as expected on thumbnails.php pages.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #13 on: December 17, 2013, 10:34:46 am »

I guess my safest bet is to just change the image itself.  Im just not php knowledgeable enough to change functions across multiple files I have no idea where to begin.
Logged

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Customizing the thumbnails based on theme
« Reply #14 on: December 17, 2013, 10:52:01 am »

I would have thought that modifying the functions.inc file would have effected all parts of the gallery using the thumb, not just the thumbnails.php
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customizing the thumbnails based on theme
« Reply #15 on: December 17, 2013, 10:59:51 am »

Obviously you also have to change it at other places. Simply replacing the image file seems to be the easiest, fail-safe solution.
Logged
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 20 queries.