How to set thumbnail of an empty / keyword album? How to set thumbnail of an empty / keyword album?
 

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

How to set thumbnail of an empty / keyword album?

Started by parabola, December 03, 2007, 01:59:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

parabola

Quote from: Nibbler on November 29, 2007, 12:45:04 PM
You can set the album thumbnail manually in the db if you feel comfortable doing that. For the album list view, either enable the config option to show the number of linked file or search the board for instructions to remove it completely.

I tried updating the thumb field in the table cpg_albums but it still won't use them as the thumbnail. Do I need to something else to make that happen?

Any help would be appreciated!

Regards,
parabola

Joachim Müller

Quote from: parabola on December 03, 2007, 01:59:25 PM
I tried updating the thumb field in the table cpg_albums
What exactly did you do? Post your changes. A deep link to the page in question might help as well.

parabola

Ok, here's the page in question: http://hillmanchan.net/cphoto/index.php?cat=11

As u can see, there's no thumbnail for the album "A Bug's Life". To confirm that, I ran the SQL:

SELECT thumb FROM cpg_albums WHERE aid = 95

and thumb returns 0. So I changed thumb:

UPDATE cpg_albums SET thumb =7362 WHERE aid =95

Image 7362 is the one I used for another album, so I'm pretty sure that it exists: http://hillmanchan.net/cphoto/displayimage.php?pos=-7362

My suspicion is, there could be some piece of code that always not use a album thumbnail when it's empty.... or do I need to update somewhere else?

Joachim Müller

Why do you run queries instead of just using the album properties screen?
You are running cpg1.4.10 btw, while the most recent stable release is cpg1.4.14 - upgrading is mandatory!

parabola

The album properties screen says "Album is empty" and won't let me choose a thumbnail.

Joachim Müller

What's the use of an empty album having a thumbnail assigned to it?

parabola

It's a keyword album. U don't add any pictures into it. Just specify a keyword for the album and it'll pick up all photos with that keyword.

Check this link and open the album: http://hillmanchan.net/cphoto/index.php?cat=11

parabola

Quote from: GauGau on December 04, 2007, 08:25:44 AM
Why do you run queries instead of just using the album properties screen?
You are running cpg1.4.10 btw, while the most recent stable release is cpg1.4.14 - upgrading is mandatory!

I just upgraded to 1.4.14 from 1.4.10 but it still shows no thumbnail for these albums.

Joachim Müller

Documentation > Known Issues:
QuoteNo album thumbnails for albums that contain only pics linked by keyword

parabola

No wonder... I had a look in index.php and "Inserts a thumbnail if the album contains 1 or more images" looks more like a feature than a known issue. Anyway, I've hacked it shows the album thumbnails OK now! Here's the patch:

$ diff -uN index.php index.php.new
--- index.php   2007-12-05 18:07:07.911450000 +0800
+++ index.php.new       2007-12-05 18:09:37.799344000 +0800
@@ -498,7 +498,7 @@
         $visibility = $alb_thumb['visibility'];

                 if (!in_array($aid,$FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
-            if ($count > 0) {
+            if (true) {
                 if ($alb_thumb['filename']) {
                     $picture = &$alb_thumb;
                 } else {
@@ -660,7 +660,7 @@
         // Inserts a thumbnail if the album contains 1 or more images
         $visibility = $alb_thumb['visibility'];
                 if (!in_array($aid,$FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { //test for visibility
-            if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images
+            if (true) { // Inserts a thumbnail if the album contains 1 or more images
                 if ($alb_thumb['filename']) {
                     $picture = &$alb_thumb;
                 } else {


Should it be included in the next release? Or would it break something else by doing that?

Joachim Müller

You would have to come up with a method to allow users to select the thumbnail from the properties screen as well. The method you perform (modifying the database itself) is not what you can expect from regular users.

adipisicing

Is anyone currently using this patch? Does it cause any problems?

I understand it isn't a complete solution, but it seems like the least modification necessary to give thumbnails to empty albums.
Unless otherwise noted, all code that I post on these forums to which I hold the copyright is released under the GPLv2.

adipisicing

I've applied this patch to my gallery installation. Everything seems to be working fine (so far, at least).

Keep in mind that, with this patch, empty albums whose thumbnails have not been manually set by modifying the database display no thumbnail image, instead of the placeholder image they normally do.
Unless otherwise noted, all code that I post on these forums to which I hold the copyright is released under the GPLv2.

adipisicing

Quote from: adipisicing on January 08, 2008, 12:10:20 AMEverything seems to be working fine

Of course, I spoke too soon.

Updating the properties for an "empty" album will make the database forget the custom thumbnail you applied.

I should be able to find a workaround to this.
Unless otherwise noted, all code that I post on these forums to which I hold the copyright is released under the GPLv2.

adipisicing

Workaround found.

in modifyalb.php in form_alb_thumb:
change
                        <input type="hidden" name="$name" value="0" />

to
                        <input type="hidden" name="$name" value="$ALBUM_DATA[$name]" />

This is line 205 as of cpg 1.4.14.

After applying this workaround, updating the properties of an "empty" album will preserve the album's existing custom thumbnail.

Unless otherwise noted, all code that I post on these forums to which I hold the copyright is released under the GPLv2.

parabola

Hi adipisicing,

I tried your workaround for modifyalb.php in 1.4.18 and found no problem with it so far. Thanks for the contribution!

Regards,
parabola

Ludo

#16
Quote from: Joachim Müller on December 06, 2007, 07:48:31 AM
You would have to come up with a method to allow users to select the thumbnail from the properties screen as well.
Done! ;)
Here is a mod that will display in the thumbnail selection listbox, for all albums, both uploaded and linked files.

DEMO: http://vanrokken.altervista.org/ (Album Fiori)

FILES TO EDIT: 2
index.php
modifyalb.php


OPEN
index.php

FIND (2 times)
if ($count > 0) {

REPLACE WITH
if ($count > 0 || $alb_stat['link_pic_count'] > 0) {


OPEN
modifyalb.php

FIND
    global $CONFIG, $ALBUM_DATA, $album, $lang_modifyalb_php,$USER_DATA;

REPLACE WITH
    global $CONFIG, $ALBUM_DATA, $album, $lang_modifyalb_php, $USER_DATA, $FORBIDDEN_SET_DATA;

FIND
    $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} WHERE aid='$album' AND approved='YES' ORDER BY filename");

REPLACE WITH
    (count($FORBIDDEN_SET_DATA) > 0) ? $forbidden_set_string = "AND aid NOT IN (".implode(",", $FORBIDDEN_SET_DATA).")" : $forbidden_set_string = '';   
    ($ALBUM_DATA['keyword']) ? $where_string = " (aid='$album' OR (keywords LIKE '%{$ALBUM_DATA['keyword']}%' $forbidden_set_string))" : $where_string = "aid='$album'";       
    $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} WHERE $where_string AND approved='YES' ORDER BY filename");



SAVE AND CLOSE ALL FILES

EDIT: added check on private albums. I don't have any private album on my gallery, so I can't test it

GH

I need to have on my only linked images album named "fuori"I an album thumbnail. I tried the mod by ludo, but there is no result for me. Running in the admin tool the fonction for creating thumbnails for the album has no result on my public album with only linked files ??
It appears:

Updating thumbnails and/or resized images, please wait...
albums/fuori/thumb_GALLERATI_Compressore.jpg updated succesfully !
albums/fuori/normal_GALLERATI_Compressore.jpg updated succesfully !
albums/fuori/thumb_GALLERATI_Grandialberghi.jpg updated succesfully !
albums/fuori/normal_GALLERATI_Grandialberghi.jpg updated succesfully !
albums/fuori/thumb_Muenchen_Kreillerstrasse_20x30.jpg updated succesfully !
albums/fuori/normal_Muenchen_Kreillerstrasse_20x30.jpg updated succesfully !
albums/fuori/thumb_Muenchen_Josephsburg_DSC2502_.jpg updated succesfully !
albums/fuori/normal_Muenchen_Josephsburg_DSC2502_.jpg updated succesfully !
albums/metro/thumb_Madrid_Nuevos_Ministerios__DSC3224.jpg updated succesfully !
albums/metro/normal_Madrid_Nuevos_Ministerios__DSC3224.jpg updated succesfully !
albums/metro/thumb_Lyon_place_Jean_Jaur_s__DSC0854.jpg updated succesfully !
albums/metro/normal_Lyon_place_Jean_Jaur_s__DSC0854.jpg updated succesfully !
albums/metro/thumb_Lisboa_Saldanha__DSC5030.jpg updated succesfully !
albums/metro/normal_Lisboa_Saldanha__DSC5030.jpg updated succesfully !
albums/metro/thumb_Lisboa_Bela_Vista__DSC4784.jpg updated succesfully !
albums/metro/normal_Lisboa_Bela_Vista__DSC4784.jpg updated succesfully !
albums/metro/thumb_Madrid_Nuevos_Ministerios__DSC3312.jpg updated succesfully !
albums/metro/normal_Madrid_Nuevos_Ministerios__DSC3312.jpg updated succesfully !
albums/metro/thumb_U_Bahn_Essen_HBF__DSC1285.jpg updated succesfully !
albums/metro/normal_U_Bahn_Essen_HBF__DSC1285.jpg updated succesfully !
albums/metro/thumb_U_Bahn_Essen_HBF__DSC1262.jpg updated succesfully !
albums/metro/normal_U_Bahn_Essen_HBF__DSC1262.jpg updated succesfully !
albums/metro/thumb_U_Bahn_Muenchen_Gern__DSC9642_.jpg updated succesfully !
albums/metro/normal_U_Bahn_Muenchen_Gern__DSC9642_.jpg updated succesfully !

back to main

So I believe that this function create the image thumbnails inside the albums, but not the thumbnail of the album, true? How to do to have the album thumbnail?

Ludo

#18
After applying mod, you should select album thumbnail in Album properties page, exactly like for albums with uploaded pictures. There is no point in updating thumbnails with Admin tools.

GH