Forum

Thread tagged as: Question, Problem, Gallery

Ghost images in gallery?

I have a gallery which I'm trying to sort on a webpage by one of the image fields using <perch if: different> on a small template to generate a list of the different "categories" of image. I was getting some repeated results at the end of the list so I tried to debug and found that perch_gallery_images() is returning some empty results in between the last couple of images in the gallery and hence creating false positives for <perch if: different>.

Indeed, there are 36 returns for a gallery of 33 images. I never noticed before because this site usually filters the gallery by an "include" field.

Is this normal behaviour? Might these be photos that were previously deleted? Is there a way round this? Apologies if I'm being stupid in some way I haven't realised...

Owain Browne

Owain Browne 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Please post your Diagnostic Report and the relevant template so we can take a look.

Perch: 2.8.7, PHP: 5.6.8, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.8.7), assets (2.8.7), categories (2.8.7), perch_blog (4.1), perch_gallery (2.8.6) App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_gallery/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); include(PERCH_PATH.'/core/apps/categories/runtime.php'); ?> PERCH_LOGINPATH: /perch PERCH_PATH: /customers/b/4/3/owainbrowne.com/httpd.www/perch PERCH_CORE: /customers/b/4/3/owainbrowne.com/httpd.www/perch/core PERCH_RESFILEPATH: /customers/b/4/3/owainbrowne.com/httpd.www/perch/resources Image manipulation: GD PHP limits: Max upload 96M, Max POST 96M, Memory: 128M, Total max file upload: 96M Resource folder writeable: Yes SCRIPT_NAME: /perch/core/settings/diagnostics/index.php REQUEST_URI: /perch/core/settings/diagnostics/ HTTP_HOST: owainbrowne.com DOCUMENT_ROOT: /customers/b/4/3/owainbrowne.com/httpd.www

        <li>

            <a href="?s=<perch:gallery id="photo_Show_slug" />"><perch:gallery id="photo_Company" />
        <perch:if different="photo_Show_slug">
        *</perch:if></a>
        </li>

That's the relevant part of the template - not how I will actually use it but for debugging after finding the problem... this is what showed me the empty images in the gallery...

This is how the page is accessing the gallery:

        <div id='gallery'>
        <h3>Gallery</h3>
        <?php perch_gallery_images(array(
            'template' => '_list_shows.html',
            )); ?>
        <?php 
            if (perch_get('s')) {
                perch_gallery_images( array(
                'filter'=>'photo_Show_slug',
                'match'=>'eq',
                'value'=>perch_get('s'),
                ));
            } else {

                perch_gallery_images( array(
                'filter'=>'include',
                'match'=>'eq',
                'value'=>'true',
                ));
            }
        ?>

        </div>   

www.owainbrowne.com/picturestest.php if you're interested!

Sorry for the multiple posts but I should just add that the admin interface does in fact say there are 36 images though there are only 33 when you click through to the album listing... I just never actually counted before!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Did you have any failures when uploading?

The nature of how uploads can fail (PHP running out of memory and completely stopping) can mean that sometimes things get left in a mess.

Somewhere in the upgrade cycle things were broken for a while and I was unable to upload new images or save changes to old ones. I thought I'd broken a template at the time. Was on perch 2.3 and the last but one gallery... upgraded to latest Perch with no joy but then also to latest gallery and all was well again. Likely something got fudged in the process...

Is there any simple way I could list all the image ids in the database then compare them with the actual entries and delete the rogue ones manually? It would be quite a hassle to rebuild the album from scratch...

Drew McLellan

Drew McLellan 2638 points
Perch Support

In your perch2_gallery_images do any have an imageStatus of anything other than active ?

No, but there are 3 with imageDynamicFields as NULL... and their imageOrder numbers put them in the right part of the album to break what I was trying to do...

Edit: they actually have the same imageOrder as the last 3 images of the gallery... (I didn't notice this because I'm in Australia at the moment and it's late.)

Is it safe just to delete them from the database?

Edit again: well with a backup of the database I took the risk and all appears well now... thank you for pointing me in the right direction. I sort of expected with perch having developed so much since I last spent any time playing with it that this level of customer support might have dropped off... really grateful that it hasn't!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that should be perfectly safe!