forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: sharpo on January 26, 2006, 12:44:36 am

Title: Paypal shop hack: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 12:44:36 am
Just noticed the "nopic" thumbnail image does not show when I create a new album, but if I upload an image (or images) into the album then one of those will appear as the thumbnail.

At the moment I am setting up a new gallery using 1.4.3 with "full size access" & "paypal shop hack" mods added. The only other alterations are a new theme based on classic with just adjustments to colours used - nothing too serious.

I have searched and found the following to be a known fault - "No album thumbnails for albums that contain only pics linked by keyword" as I had already attempted creating an album for linked pics and noticed there was no thumbnail image, but has that had a knock on effect with other new albums I create?

I have done a "view source" on a 1.4.2 gallery that does work and the same for a 1.4.3 gallery that doesn't

This is the one that works:-

<!-- Start standard table -->
<table align="center" width="100%" cellspacing="1" cellpadding="0" class="maintable">

        <tr class="tableb_compact">

        <td width="17%" valign="top">
        <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
                <td colspan="3" height="1" valign="top" class="tableh2">
                        <span class="alblink"><a href="thumbnails.php?album=114"><b>nopictest</b></a></span>
                </td>
        </tr>
        <tr>
                <td colspan="3">
                        <img src="images/spacer.gif" width="1" height="1" border="0" alt="" /><br />
                </td>
        </tr>
        <tr>
                <td align="center" valign="middle" class="thumbnails">
                        <img src="images/spacer.gif" width="102" height="1" class="image" style="margin-top: 0px; margin-bottom: 0px; border: none;" alt="" /><br />
                        <a href="thumbnails.php?album=114" class="albums"><img src="images/thumb_nopic.jpg" width="100" height="75" class="image" border="0" alt="" /><br /></a>
                </td>


---------------------------------------------------------------------------------------------------------------


This is the one with the missing nopic.jpg:-

<!-- Start standard table -->
<table align="center" width="100%" cellspacing="1" cellpadding="0" class="maintable">

        <tr class="tableb_compact">

        <td width="25%" valign="top">
        <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
                <td colspan="3" height="1" align="left" valign="top" class="tableh2">
                        <span class="alblink"><a href="thumbnails.php?album=6"><b>test3</b></a></span>
                </td>
        </tr>
        <tr>
                <td colspan="3">
                        <img src="images/spacer.gif" width="1" height="1" border="0" alt="" /><br />
                </td>
        </tr>
        <tr>
                <td align="center" valign="middle" class="thumbnails">
                        <img src="images/spacer.gif" width="102" height="1" class="image" style="margin-top: 0px; margin-bottom: 0px; border: none;" alt="" /><br />
                        <a href="thumbnails.php?album=6" class="albums"><img src="" width="0" height="0" class="image" border="0" alt="" /><br /></a>
                </td>

Hope I have explained it clearly. I can see where the problem is, but not what is causing it.

Thanks for any help you can offer.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 08:35:27 am
Hey!  My Coppermine is doing that too!  I didn't know it wasn't supposed to do that.  That's pretty funny.

In my case, I figured out the issue.  I have a possibly strange thumb prefix; it's "thumbs/thumb_" so each album folder has a folder called thumbs where I have all my thumbs & intermediate images.  I don't remember if this setting worked out of the box or if I modified something.

So I had to create a thumbs folder in the images folder and copy the thumb_ images (including thumb_nopic.jpg) to this images/thumbs folder.  Then the nopic image showed up fine and I didn't have the img src="" anymore.

My guess for your case (unless you happen to have the exact same folder feature in your prefix) is that you changed the thumb prefix to something else and there's possibly a bug in the Coppermine code in that it uses your custom thumb prefix to try to find the images/thumb_ images and of course they are all named with the default prefix of thumb_.

If you do have a custom thumb prefix, please try to rename or copy thumb_nopic.jpg to YOURTHUMBPREFIX_nopic.jpg and see if that works.  If it does, please post here so I can look into this possible bug.

If you have the default thumb prefix, also let me know and we can postulate another possible cause.  As I said, my img src="" is now fixed (with a band-aid to be sure).
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Joachim Müller on January 26, 2006, 09:08:25 am
@Paver: is this a bug or at least something that should be noted in the docs? If yes, please move this thread to the bugs board.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 09:19:16 am
Hey!  My Coppermine is doing that too!  I didn't know it wasn't supposed to do that.  That's pretty funny.

Is this a minor problem with all versions of 1.4.3 then?

I had previously looked in the images folder and noticed that the files such as nopic.jpg & txt.jpg did not have thumb_ preceding the name, but thought there may have been reasons for this, so did not take any notice. Since reading your message, I have changed nopic.jpg to thumb_nopic.jpg & it works fine.

My 1.4.3 was downloaded from this site, so should have been a "proper" version.


Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Joachim Müller on January 26, 2006, 09:25:28 am
as I suggested in my previous posting: we're trying to determine if this is a bug. Please allow some time for Paver to reply.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 09:38:00 am
Sorry GauGau, I started my reply before your posting was added - I must be a slow writer.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 04:25:36 pm
I didn't have time last night to investigate further.  I just tried the simple thing I noted and it worked.  I also wondered about the missing thumb_ at the beginning of nopic.jpg (based on something I saw in the code), but since mine said thumb_nopic.jpg, I didn't think about it (yet).

Once I look into this (soon), I'm sure it will be easy to classify & fix if necessary.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Blueiris on January 26, 2006, 06:59:16 pm
I'm not comfortable that this is a bug, because my test install of cpg1.4.3. shows the thumb_nopic.jpg for an empty album just as it should, and that's basically an out-of-the-box install.

http://www.goldiris.com/Coppermine/ (http://www.goldiris.com/Coppermine/)

You can see two empty albums on the home page, and if you go to User galleries > Blueiris, there is a third. (It's OK to register and play with that install - it's a testbed)

The default thumb_nopic.jpg resides in the top level images folder, (not under themes or albums) so "images/thumb_nopic.jpg" in the code is correct.

Display can be controlled thru theme.php - see sample/theme.php - look for "// HTML template for the album list," then go down near line 280. It's also in theme.inc.php, so if that's been altered it might have an effect.

I'm not sure why this wasn't working for sharpo and Paver, but I know it's worked properly in my test installs on my PC and in my public gallery, too. We dont' need to get out the bug spray if there isn't a bug, but I'm sure we should figure out what is different between these installs.

Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 07:22:46 pm
Right, I agree.  That's why I haven't moved it yet.  Thanks for your input.  I have a few suspicions and will dive into the code to figure out what's going on.  My setting of using a sub-folder for the thumb prefix may not be supported out of the box, so I don't presume to say this is a bug if it's just my wacko setting.  I will certainly figure out if nopic.jpg could have been renamed in the code - that's one of my suspicions.

I will post once I figure it out.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 07:58:17 pm
A quick update.  (I have some chores to do so don't know if I'll finish the full investigation now.)

First of all, my sub-folder in the thumb prefix is not supported out of the box, so let's put that aside.

The main issue I see with a new install of 1.4.3 is this:

I suspect there might be an images/ rename for upgrade installations, but I haven't looked yet.

@sharpo: Is your installation a brand new one or an upgrade?  If an upgrade, from which version?  If a new one, did you change the thumb prefix at all?

I wouldn't consider this a bug yet.  Having someone do what I did is rather rare I would think, so I'm not sure if more common actions would cause the mis-rename.  I do think that Coppermine shouldn't produce a blank img src even if no images can be found (for whatever reason), so I might consider this an issue and want to fix it still, but I'll decide this when the investigation is complete.  Others are welcome to join in, but I'm willing to do this myself as well.

Oh, I realize that having a blank thumb prefix doesn't make sense, so I don't consider making the thumb prefix blank and then non-blank a bug, according to the "rules" of having a thumb prefix.  It's an issue to consider for people who actually do that.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 08:10:27 pm
Just had the idea to check the files created when I unzipped the original download of 1.4.3 & that shows those files such as "nopic.jpg" all had thumb_ as a prefix. This means one of those mods/hacks mentioned in the original posting may have renamed the original files?

I can assure you that I haven't modified the names of any of those .jpg files. Hope this helps you solve this query.

I might have some other backups which might indicate at what point the file names were "changed", if I find them will post a message later


****Quick amendment, Paver posted while I was typing the above (proves I am a slow typist) and I will answer as follows:-
The installation was a brand new one.
I made no alterations to the thumb prefix.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 08:23:37 pm
You mentioned 2 mods/hacks.  Is the full-size access mod you mention the plugin "Full-Size Photos Access Control"?  I wrote this plugin and it doesn't rename any files.  It just removes the full-size link on the displayimage page.

Please describe which mods you mean, in case it's related.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 08:48:35 pm
You mentioned 2 mods/hacks.  Is the full-size access mod you mention the plugin "Full-Size Photos Access Control"?  I wrote this plugin and it doesn't rename any files.  It just removes the full-size link on the displayimage page.

Please describe which mods you mean, in case it's related.

Yes, Paver, it is your plug-in, version 1.2 as in topic 25010
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 26, 2006, 08:52:43 pm
And which Paypal shop hack?
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 09:01:33 pm
And which Paypal shop hack?

Started with the Madeinhawaii one, topic 22357.40 then replaced it with the Casper version topic 26454
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 26, 2006, 10:37:27 pm
Looks like I backed up my site on the 20th & "thumb_" was the prefix on such files as nopic.jpg

Soon after that I download Casper's paypal shop hack - topic 26454, and it must have been after that when "thumb_" prefix disappeared.

Hope that helps narrow it down a bit.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Blueiris on January 26, 2006, 10:58:56 pm
I *might* have found the cause, but since I don't claim a heavy expertise in PHP, I'm not 100% sure this is the culprit. It is in Casper's paypal hack, in the shop.php. At line 136, there is the following code:

Quote
        // Code to rename system thumbs in images folder
        $old_thumb_pfx =& $CONFIG['thumb_pfx'];

        if ($old_thumb_pfx != $_POST['thumb_pfx']) {
            $folders = array('images/', $THEME_DIR.'images/');
            foreach ($folders as $folder) {
                $thumbs = cpg_get_system_thumb_list($folder);
                foreach ($thumbs as $thumb) {
                    @rename($folder.$thumb['filename'],
                            $folder.str_replace($old_thumb_pfx,$_POST['thumb_pfx'],$thumb['filename']));
                }
            }
        }

This is the same code that is used in update.php to rename the thumbs in the top level images folder when updating Coppermine. Perhaps Paver or GauGau can clarify my thinking here, but it looks to me as through this code in shop.php is reading thumb_pfx from cpg143_config as the old thumb prefix, and replacing it in the filename with nothing.

I'll await a more expert opinion!

Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 27, 2006, 12:39:46 am
Blueiris: I'm sure you found it - good job.  That's saves me some time. 

First of all, everything I said above about producing the problem on my computer is moot for this particular thread.  Please ignore it.  (I will use the information for my own uses, but it's unrelated to sharpo's original problem.)

Second of all, Casper copied the code you mentioned from admin.php, not update.php.

So here's my guess.  Let's start at the beginning.  Coppermine apparently uses the thumb prefix everywhere, for all thumbs, including the system ones in the core images/ folder.  (Something I'm going to take up with the devs.)  So whenever you change the thumb prefix, it renames the images/thumbs to use the new thumb prefix.  It also renames the thumbs in the current theme/images as well, but only the current theme.  If you happen to change the thumb prefix and then change to a new theme that has its own images/thumbs, the thumbs won't have the correct prefix.  (I haven't reproduced this supposed error yet.)  The core themes actually don't have any custom thumbs, so this issue only occurs for other themes that have custom thumbs.  I only mention this for reference; it's not related I don't think to this issue, but it might be if Casper wanted to make sure the theme's custom thumbs are correct.  As I mention below, I have no idea besides this one why he bothers to rename the thumbs.

Casper's hack also renames the thumbs in the core/images and the theme/images, but it does this when you configure the Paypal shop, every time.  I'm not sure why.  The problem is that he uses the $_POST['thumb_pfx'] which is not defined by his form; it *is* defined by the config panel form (in admin.php), so when you change the thumb prefix, it will use the new setting you set (in $_POST['thumb_pfx']) to rename the thumbs as I said.

So, $_POST['thumb_pfx'] is blank and all the core thumbs are renamed to have no thumb prefix.  This is the problem that sharpo found.  It's a bug in the Paypal shop hack, but it does highlight an issue I think exists in the core code about renaming the thumbs.  I will discuss this information with the devs.

In the end, I think this thread belongs in the Mods board.  I'll modify the title to reflect the Paypal shop bug.   I don't think it's instructive to merge it with the Paypal shop thread, but I will post on that thread with a link to this thread.

But first:
@sharpo: Could you try to configure your Paypal shop and hit submit?  You don't have to change anything, just go to the config page, then submit.  My guess is that it will rename your core images/thumbs and you'll have the same blank img src that started this thread.  If so, please let me know, so I can close this issue as "Solved".  Of course, after you do this, just rename the thumbs again.   ;)
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 27, 2006, 12:47:27 am
I think I figured out why Casper has this rename code in his shop.php.  At first, I couldn't figure out why if $lang_shop_data is not defined, he uses $lang_config_data since $lang_config_data is not present anywhere in the lang file.  Then I realized that what he really means is $lang_admin_php which is the new config form.  So if his config elements are not present, he reproduces the admin config panel and needs to process those form elements as they are in admin.php.  I assume $lang_config_data came from version 1.3's config.php.

In any case, if this really is the issue sharpo has, I'll bring it up on Casper's thread for him to decide what to do. 
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 27, 2006, 01:09:23 am
Blueiris: I'm sure you found it - good job.  That's saves me some time. 

@sharpo: Could you try to configure your Paypal shop and hit submit?  You don't have to change anything, just go to the config page, then submit.  My guess is that it will rename your core images/thumbs and you'll have the same blank img src that started this thread.  If so, please let me know, so I can close this issue as "Solved".  Of course, after you do this, just rename the thumbs again.   ;)

Did what you suggested, Paver, and sure enough - ended up with the blank img src

So as it stands at the moment, if I make any alterations to the Paypal shop I will have to add thumb_ to any of those images such as nopic.jpg that I might be using. Nothing too drastic really, as long as there is nothing else awaiting me "round the corner" so to speak.

Well spotted to Blueiris, as well.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 27, 2006, 01:34:39 am
@sharpo: Very good.  The solution for you would be to delete the lines Blueiris listed.  They are not necessary at all for the Paypal shop hack unless you change languages.  I just realized that this must be why Casper put that in there.  If you don't have a hacked language file to include $lang_shop_data, then you cannot config his Paypal shop, so he just shows the admin panel and wants to process this form as I said before.  Ideally, he should have an English fallback just for his $lang_shop_data, but that will take some coding.  I don't think he should put up the admin panel & process it as a fallback.  That seems weird to me.

So the solution is to hack the hack.  Open up shop.php and remove those lines Blueiris listed.  That should do it for you.

I'll move this thread, rename it, and mark it as "Solved".  Then I'll put up a post on Casper's thread to inform him of the problem.  Of course, his hack is still in 'beta' so I'm sure he won't be surprised.   ;)

Well done, everyone.

p.s. Please do *not* post additional questions regarding this issue here.  Please use Casper's thread on the Paypal shop hack:
http://forum.coppermine-gallery.net/index.php?topic=26454.0 (http://forum.coppermine-gallery.net/index.php?topic=26454.0).  I didn't merge this thread with that one for simplicity, but additional queries should go in the "home" thread.
Title: Re: Paypal shop hack: img src="" for empty album, where is nopic.jpg?
Post by: Joachim Müller on January 27, 2006, 06:10:01 am
Moved this thread back from the mods board to the support board where it belongs. Only actual mods go into the mods board, not fixes for mods. Instead, you should post in the thread that deals with the mod, refering to the fix. The mod author may then decide to apply the fix to his mod (or not).
Title: Re: Paypal shop hack: img src="" for empty album, where is nopic.jpg?
Post by: Paver on January 27, 2006, 06:16:14 am
Ah, OK - understood.  That does make sense.
Title: Re: img src="" for empty album, where is nopic.jpg?
Post by: sharpo on January 27, 2006, 07:36:01 pm

So the solution is to hack the hack.  Open up shop.php and remove those lines Blueiris listed.  That should do it for you.


That seems to have corrected the problem, thanks to Blueiris for showing which lines to remove.
Title: Re: Paypal shop hack: img src="" for empty album, where is nopic.jpg?
Post by: Casper on January 30, 2006, 05:03:18 pm
Ooops.

yep, my fault.  I didn't put this code in as such, I just forgot to remove it from the code I copied from the admin.php.

I will update the download and put the fix on the hack thread.  As noted, this is a beta, and those that know my hacks know they never come without needing a fix or 3.  ;D