Forum

Thread tagged as: Discussion, Gallery

Placement of 'image.php' and how to use Gallery addon

I see that for all the addons (Events and Blog, at least), the page functions will output content onto pages, but the links to individual items -- blog posts or event pages -- return 404 errors until you copy over the folders containing the starter templates (from the download zip files) into the site root. Then there is something when you click on a specific event or blog post item.

Gallery seems to work a little differently. I used perch_gallery_build() to output image thumbnails. Clicking a thumbnail caused a 404 with a URL dependent on an image.php being present at the site root.

Simply copying the folder named gallery from the addon download doesn't work, even though that's all I needed to do for all the other addons. I found a file named image.php in the subdirectory example-b in the gallery folder. After I copied that file into the the site root and hacked the include() function at the top to point to the runtime file from the site root instead of from two levels deep, clicking on an output image thumbnail finally works.

But this doesn't seem like the right way to use the gallery. I also notice that Events and Blog both have an option in the Settings were you can change their URL structure. Gallery has no similar option.

So, I'm curious what the intended structure for gallery pages is supposed to be.

Paul Lee

Paul Lee 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I wouldn't advise using perch_gallery_build() as part of your workflow - it's more of a quick demo so you can see things working.

The links really come down to the href attributes in your template, which will be dependant on how your want to structure your gallery. There's no intended structure - it's really up to you.

I made gallery pages that are actually just links in Perch going to the same album.php file with different slugs, and it works well---except that it doesn't work for two of the three albums---the <img> elements that render fine when one of the album slugs is passed to the album.php file simply don't exist when one of the other two slugs is used.

I know the URL identifiers for those two albums are correct because the function perch_gallery_album_field(perch_get('s'), 'albumTitle') does successfully show the album titles for all the albums, including the ones where there are no image elements.

This is the relevant part of my album.php file:

  <div class="module-flex_row callout-heading">
    <h2><?php perch_gallery_album_field(perch_get('s'), 'albumTitle'); ?></h2>
  </div>

  <div id="main-slider-parent">
    <?php
      if(perch_get('s')) {
        perch_gallery_album_images(perch_get('s'), array(
          'template' => 'gallery_carousel.html'
        ));
      }
    ?>
  </div>

And this is the template gallery_carousel.html:

<perch:before><div class="flexslider">
    <ul class="slides"></perch:before>
        <li class="slides album">
            <perch:if exists="carousel"><img src="<perch:gallery id="carousel" />" alt="<perch:gallery id="imageAlt" />" height="<perch:gallery id="carousel-h" />" width="<perch:gallery id="carousel-w" /> "/></perch:if>
        </li>
    <perch:after></ul>
</div></perch:after>

I wonder if for some reason the Gallery app didn't make the carousel versions of the images for the other two albums, which I defined in my version of image.html:

<perch:gallery id="image" type="image" key="carousel"  width="683" crop="true" />
<perch:gallery id="image" type="image" key="main"  width="464" />
<perch:gallery id="desc" type="textarea" label="Description" size="s" textile="true" editor="markitup" />

Maybe this is an issue with my dev environment's server settings, so here's the diagnostic too:


Perch: 2.8.31, PHP: 5.6.23, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO Server OS: WINNT, apache2handler Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_events (1.9.3), perch_forms (1.8.3), perch_gallery (2.8.6), perch_backup (1.2) App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_events', 'perch_forms', 'perch_gallery', 'perch_blog', ); PERCH_LOGINPATH: /perch PERCH_PATH: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch PERCH_CORE: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\core PERCH_RESFILEPATH: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\resources Image manipulation: GD PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M F1: 2edba60ed1f613d6dd804feb202456a2 Resource folder writeable: Yes HTTP_HOST: dev1.lakehouse DOCUMENT_ROOT: C:/Users/Webmaster-Lobby/Websites/xampp/htdocs/Sites/lakehouse1 REQUEST_URI: /perch/core/settings/diagnostics/ SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the difference between those that work and those that don't?

The most obvious difference is that the one that works only has 11 images in the album, while the two that don't work have 58 and 42 images.

I wonder if some server problems are capping the number of images being output, but I don't even understand it enough to know if that's a very sensible guess.

The working album is position 3 in the album list in the Album Options. The others are 1 and 2, but I think they both erroneously might have been at position 2 before I just corrected it.... but still after ensuring that they all have different position values, only the one works.

I just made a new gallery with 21 images -- half the images from one of the albums that won't render.

I made a page reference in the dashboard to pass its identifier in the URL to the album.php file, and it works!

So, it looks like this has to do with the number of images.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do the images upload successfully?

Do you get any errors logged?

Drew McLellan said:

Do the images upload successfully?

Yes.

Drew McLellan said:

Do you get any errors logged?

No. I tested by making a master album with 288 images. I uploaded the images in batches, and every time I uploaded a group of images I checked the error.log file located at xampp\apache\logs\ in my environment, and nothing new was added to the file during the uploading.

I will probably split the albums into smaller groups, since massive carousels are probably not a great design idea anyways.

Edit: I marked the first reply to my original post in this thread as the solution, since I verified that using URL slugs (in hrefs, etc) is the right way to use the Gallery addon.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not aware of a limit that would affect the display of albums if the images all upload correctly.

I've discovered why the image tags were empty for the larger albums. It actually doesn't seem to have anything to do with the number of images in the albums.

My custom template gallery_carousel.html is dependent on an image type carousel defined in my version of image.html. I didn't save these templates in perch/templates/gallery until after I had uploaded the first two albums.

Now, I've deleted those two albums and re-created them, and the image tags now render for them when output from my template. So, presumably the new image type defined in image.html didn't get created for the albums that were defined before I made my version of that template.