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: Custom thumbnails for categories  (Read 11748 times)

0 Members and 1 Guest are viewing this topic.

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Custom thumbnails for categories
« on: December 31, 2010, 03:24:04 am »

I'd like to be able to assign a custom thumbnail to a category that does not reside somewhere in an album in the hierarchy below it.  e.g., I have a category for my Plymouth Gallery for the Sport Fury model, and categories underneath for individuals owning that model, with their albums under that.  I'd like to show a stylized thumbnail for the category, as in the attachment.

It's possible to assign a thumbnail from one of the albums under the category - but, I'd like for the thumbnail to not be constrained to already be in any album set underneath it.  With that constraint, it must also exist within an album that is exposed to all users, and I'd prefer not to create an album with category icons only.

So I guess I'm looking for a) a way to assign a custom thumbnail to a category, independent of the images in albums below it; or b) a way to select an image for a category icon from an album that's otherwise hidden from users, for the exclusive purpose of storing category icons.

Thanks
Dan

Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Custom thumbnails for categories
« Reply #1 on: January 29, 2014, 09:20:54 pm »

An old topic I know... but a feature I would like to make use of and found this post while searching...
Would this be considered for core code? (with a volunteer offering to look at it?)

Basic thoughts:
  • 2 (hidden in 1.5.x) new config options (under Album List View in 1.6):
    - Category Custom Thumbnail Album - 'category_thumb_album' (saved as aid)
    - Show Thumbnail for Empty Category - 'category_thumb_empty' (default to 0, 1 if desired)
  • An album defined using normal albmgr process) to hold custom thumbnails - the aid would be saved in  'category_thumb_album' via config panel.  (The album CAN be hidden - visible to ADMINS only...  so no one else will see the album - it still will display the thumbnail from my testing.)
  • A mod to catmgr.php (or related functions) where developing the dropdown for selecting a thumbnail for category - adding the pics from  'category_thumb_album' if specified to the list of possible choices... For a currently empty category, these would be the only choices (today there are no choices presented).  The ability to select any existing picture in the category is of course preserved as well.
  • A mod to index.php to still display category thumbnail if:
    Category has no albums and no pictures - but cat thumbnail is specified, exists, and  'category_thumb_empty' is set...  (this part is one line mod...)
The only piece I would still need to code is the catmgr mod... I did manual db updates for my example below.

I looked at doing as a plugin, and could certainly go that route to set the thumbnail - but any change to the category (description, etc) will undo the thumbnail setting (because catmgr doesn't see it as valid).... and no way to force the cat thumbnail to be displayed for an empty category that I see with current plugin points.

Why consider empty categories? I have 2 cases where I ran into this...
- A category that  have only a minicms entry to display - with no albums under it... I use this for pointers to other galleries for example...
- A category that has only categories under it (which then may have albums) is still considered empty (how deep may vary based on the setting of 'subcat_level' - my description is based on default setting of 2...)

An example: http://greggallery.gmcdesign.com. On the main page (index.php) - all of the category thumbs are added using this technique... There are several categories at top that are 'empty' - containing only minicms content... A number of 'normal' categories with albums... and one category with only subcats directly under it ('Skymasters')...  A single 'Admin only' album contains the category thumbnails. A mod to index.php in place to allow the thumbnail display for empty category - without it .  Based on 1.5.26.  (mod will be provided based on more recent svn).

Thoughts, comments, feedback welcome...
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Re: Custom thumbnails for categories
« Reply #2 on: January 30, 2014, 11:05:18 am »

- A category that has only categories under it (which then may have albums) is still considered empty (how deep may vary based on the setting of 'subcat_level' - my description is based on default setting of 2...)
FYI: this is already fixed in the SVN repository.

IMHO creating a determined album for category pictures, upload pictures to that album and set the ID in the config sounds too complicated for the average user, though it may be a quite clean way. Instead, this should work like the custom thumbnail (for files) plugin, i.e. just select an image from your HDD and upload it. Coppermine would need to take care of the rest.

For a start, we should modify catmgr.php to keep the set category thumbnail (if it still exists) and force index.php to display it regardless of other conditions.
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Re: Re: Custom thumbnails for categories
« Reply #3 on: January 30, 2014, 03:27:52 pm »

FYI: this is already fixed in the SVN repository.
You've been busy... lol... I tested at 1.5.26... and SVN 8660... Looks like you addressed in SVN 8663?... I'll update to latest SVN and base code updates from there.

Quote
IMHO creating a determined album for category pictures, upload pictures to that album and set the ID in the config sounds too complicated for the average user, though it may be a quite clean way. Instead, this should work like the custom thumbnail (for files) plugin, i.e. just select an image from your HDD and upload it. Coppermine would need to take care of the rest.
My thought was the config panel would present a pulldown of album names - but store the aid when selected (to protect from album renames...) I wanted to be able to use all upload possibilities including batch add.. and allow management like any other album with users choice of name and whether it was visible or not to non-admin users. It did seem to be a cleaner/less code implementation.

I could implement/use a 'system album' (aid 0?).. and then add support so they could either upload at time of assigning (like custom thumbnail) or have them already there via other means and added to pulldown...  For the upload option - would need to add pic to pictures table - since not already there as in the case of custom thumb plugin. This would certainly be more code (not necessarily a lot more complexity - just more 'touch points') to include system album for uploads (if admin), batch add, ability for admin to view... (maybe less if system album is added to cpg_albums with aid 0... as I think out loud... I was thinking of implementing the system album 'under the covers'... like user gallery categories.)

Either method could be extended to allow custom thumbnail for album as well... again removing the limitation that album thumb has to come from one of it's pics...

Maybe custom_thumb could allow selection from the 'system album' as well - for consistent interface? (again via either method)

Quote
For a start, we should modify catmgr.php to keep the set category thumbnail (if it still exists) and force index.php to display it regardless of other conditions.
Agree... the display part was a one line change at 8660... Will review at curretn SVN.  And catmgr should be updated as well...

I'll look further at the code.  Ideas/thoughts always welcome.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom thumbnails for categories
« Reply #4 on: January 30, 2014, 04:16:23 pm »

An album with ID "0" is probably no good idea, as I assume we've some checks like
Code: [Select]
if (!$aid)which could make trouble.

If possible I want to avoid a special album. Instead, we need a user friendly interface to select any image which exists in the gallery (maybe by navigating through the categories and albums).
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Custom thumbnails for categories
« Reply #5 on: January 30, 2014, 06:10:13 pm »

How about the admin can create a meta album of all the images they want to use as thumbs before visiting a new interface. The new interface will have the menu items to add custom thumbs to categories, albums or specific images. With large galleries it might be useful as the admin can add their images to the meta album as they go.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Custom thumbnails for categories
« Reply #6 on: January 30, 2014, 09:09:17 pm »

Αndré
OK... so if catmgr/albmgr dispaly the normal list of thumbnail candidates by default - but with option to navigate to other categories/albums if desired... (and of course preserve any selection made previously unless explicitly changed by user.)

I'll look closer at the catmgr code - I know that has specific techniques dealing with dropdowns to handle large numbers of categories... so let me read thru and understand that... But sounds like a good approach.

I did test at SVN 8864, and the following scenario:
Cat 1 (no direct albums)
  Subcat 1
    (one or more albums)
  Subcat 2
    (one or more albums)
Cat 1 is still considered 'empty' by both catmgr (no choice to select thumbnail) and index.php in choosing not to display a thumbnail...
Unless there is a hidden option I need to set?

A one line change to index/php fixes this (actually just removing one line of code) and would support any method of custom code we have talked about...
Find: (line 428 in SVN 8864
Code: [Select]
        } elseif ($pic_count == 0 && $album_count == 0) {
            $user_thumb = str_repeat($indent, $level-1);               
            $cat_data[] = array($link, $cat['details']['description'], 'cat_thumb' => $user_thumb);
Replace With:
Code: [Select]
        } elseif ($pic_count == 0 && $album_count == 0) {
            //*GMC no pictures and no albums found... but we still might have a thumbnail. $user_thumb contains info if so - and we don't want to clear.
            //*GMC if no thumbnail, then $user_thumb already contains the data we are setting it to... so no need for this code
            // $user_thumb = str_repeat($indent, $level-1);                     //*GMC removed line
            $cat_data[] = array($link, $cat['details']['description'], 'cat_thumb' => $user_thumb);
Appears from the code an empty album will need a similar change - around line 800... but ran out of time for the moment to code/test.

Phill,
Not sure what a meta album would add?  Over being able to navigate to any cat/album and select from there?
I'm familiar with meta albums like lastupload, random... not sure how to define one as a user...

For pics, the custom_thumb plugin appears to replace in the file system the thumb for an image (and optionally the intermediate...) with no changes to the database or cpg needed... Normal code to find the thumb finds the updated file.

For cat/alb it would seem just updating the 'thumb' field with pid of image desired is all that is needed... Again normal code would find the thumb (with the one exception above fixed to display a thumb if it exists even if cat is empty...
Only change is in the interface (catmgr/albmgr) to allow selection.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Re: Custom thumbnails for categories
« Reply #7 on: January 30, 2014, 10:58:18 pm »

Appears from the code an empty album will need a similar change - around line 800... but ran out of time for the moment to code/test.
And it does...
Also in index.php:
Find: (line 806 after above change at SVN 8864)
Code: [Select]
            if ($count > 0 || !empty($alb_stats[$alb_idx]['link_pic_count'])) {                                 
                if (!empty($alb_thumb['filename'])) {
Replace with:
Code: [Select]
            //*GMC added test for existence of thumb filename even if album is empty... If thumb exists (already checked) - display it
            // if ($count > 0 || !empty($alb_stats[$alb_idx]['link_pic_count'])) {                                  //*GMC replaced
            if ($count > 0 || !empty($alb_stats[$alb_idx]['link_pic_count']) || !empty($alb_thumb['filename'])) {   //*GMC test added
                if (!empty($alb_thumb['filename'])) {

Now a specified thumbnail (if it exists) will be displayed even if the album is empty...

Once we decide the approach for assigning the thumbs, I can work on catmgr/albmgr piece... (or equivalent).
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.