Customizing the thumbnails based on theme Customizing the thumbnails based on theme
 

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

Main Menu

Customizing the thumbnails based on theme

Started by SolidSnake2003, December 15, 2013, 08:26:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SolidSnake2003

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

SolidSnake2003

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?


        // 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.");
            }
        }
    }

SolidSnake2003

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

Αndré

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.

Αndré

Quote from: SolidSnake2003 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.
Merged your two threads. Please don't double post. Instead, reply to your own related threads.

SolidSnake2003

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.

Αndré

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.

SolidSnake2003

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:



    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:


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



Αndré

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.

SolidSnake2003

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.

Αndré

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

SolidSnake2003


Αndré

Works for me as expected on thumbnails.php pages.

SolidSnake2003

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.

SolidSnake2003

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

Αndré

Obviously you also have to change it at other places. Simply replacing the image file seems to be the easiest, fail-safe solution.