Thumbs not generated (using CloudPanel one server)

Sadly nothing is generated — not on the fly when loading a page nor through the panel even when uploading new media (the same media that is successfuly converted with the resize pluging).

Yes, which makes it all the more odd why Kirby cannot seem to generate thumbs on its own.

I just added to a template:

   exec('convert -v', $output);
   dump($output);

It succesfully prints:

0
Array
(
[0] => siteowner
[1] => Version: ImageMagick 7.1.0-48 Q16-HDRI x86_64 c1ca24765:20220910 https://imagemagick.org
[2] => Copyright: (C) 1999 ImageMagick Studio LLC
[3] => License: https://imagemagick.org/script/license.php
[4] => Features: Cipher DPC HDRI Modules OpenMP(4.5)
[5] => Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib

[...]

@texnixe do you know which lines of code in Kirby trigger thumbs generation when a url is called?

I added echo ("ImageMagick command: " . $command); to ImageMagick.php at line 161.

This has revealed that the command is in fact not being triggered.

The command is however triggered by Blurry Placeholder Images for Kirby plugin, which is recorded in the log thanks to the echo ("ImageMagick command: " . $command);.

In short: I need to identify why the thumbs code is not being triggered like normal.

Thank you for all your help and patience!

And if you log before the command is executed? What code are you using in your template?

process() is called in the thumb component.

I get an error Undefined variable $output

PHP — if that is what you’re asking?

Sorry, I meant to actually see the code from your template.

Yes, $output is not defined before the exec command is executed, because that’s something exec returns.

But that means that the process() command is at least triggered.

Nothing unusual as far as I can tell

here is exhibition.php (please don’t judge my coding!)

<!-- header -->
<?php snippet('header') ?>
<!-- nav -->
<?php snippet('nav') ?>
<!-- content -->
<main id="main" class="page-container page-wrapper">

    <!-- container -->
    <div class="main-container">
        <!-- filtered result -->
        <?php snippet('exhibition/exhibition') ?>
    </div>
</main>
<!-- footer -->
<?php snippet('footer') ?>

Here is the main snippet:

<div class="main-img-container">
    <?php
    if ($page->cover()->toFile()) {
        $image = $page->cover()->toFile();
    } else {
        $image = $page->image();
    }
    ?>
    <img src="<?= $image->placeholderUri() ?>" data-src="<?= $image->url() ?>" data-lazyload alt="<?= $image->alt() ?>" />

</div>
<div class="main-exhibition-text-container">
    <?= $page->title() ?><br>
    <?= $page->startDate()->toDate("d.m.Y") ?><?php if ($page->startDate()->isNotEmpty() && $page->endDate()->isNotEmpty()) : ?>—<?php endif ?><?= $page->endDate()->toDate("d.m.Y") ?><br><br>
    <?= $page->text()->kt() ?>
</div>

<div class="layouts">
    <?php foreach ($page->layout()->toLayouts() as $layout) : ?>
        <section class="grid" id="<?= $layout->id() ?>">
            <?php foreach ($layout->columns() as $column) : ?>
                <div class="column" style="--span:<?= $column->span() ?>; --columns:<?= $column->span() ?>">
                    <?php foreach ($column->blocks() as $block) : ?>
                        <div id="<?= $block->id() ?>" class="block block-type-<?= $block->type() ?>">
                            <?= $block ?>
                        </div>
                    <?php endforeach ?>
                </div>
            <?php endforeach ?>
        </section>
    <?php endforeach ?>
</div>

Hm, but unless I’m blind I don’t see any thumb creation code?

Guess the placeholderUri() method is something provided by the blurry placeholder plugin.

This may only have been the case for the Blurry Placeholder Images for Kirby plugin, which is succesfully generating placeholder thumbs when a url is called — just the actual image isn’t having it’s thumb generated

My understanding is that thumbs method is used to generate the “thumbs” for all page media? (but correct me if I’m wrong!)

So the issue is that media uploaded through the panel results in no “thumbs” being generated in the /media/.../page directory (nor when a URL is called). Same for the panel.

So e.g., the panel looks like this:

Ok, understand. I’m almost at my wits end. Which Kirby version are you using? I guess locally everything works fine?

Yep locally everything is fine. Same on a server not using CloudPanel.

I’m using the latest Kirby 3.7.1

Me too lol!

One last pathway I could try. Do you know how I might log an error in the Kirby code so that any failure of media thumbs generation when uploading an image via the panel might be seen?

Hey, just wanted to bring this thread back from limbo to say that I was able to solve this issue on my end with the thumbnail generation not working on CloudPanel by removing some code from my nginx Vhosts config file. Specifically, I removed the following lines:

location ~* ^.+.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}

I was cracking my head open with this one, but thankfully it turned out to be a simple solution.

I figured this one out by seeing that I could not access any file with the extensions mentioned in that line. I asked ChatGPT about this and it kinda explained it pretty well:

This location block is defining a regular expression that matches any URL path that ends with a file extension specified in the parenthesis. The directive add_header Access-Control-Allow-Origin "*", adds a response header Access-Control-Allow-Origin with a value of *, which allows any website to access the content of the resource.

The expires directive sets a cache expiration time for the resources, which is set to max, indicating that the resource should be cached indefinitely. The access_log directive is set to off, disabling access logging for these types of resources.

It’s possible that this block was causing issues because it was too broad in its matching and was potentially interfering with other parts of the configuration. However, if you want to enable the Access-Control-Allow-Origin header for specific resources, you can modify this block to match only those specific resources instead of matching all files with certain extensions.

Hope this helps someone else who may be experiencing a similar issue with Kirby in CloudPanel servers/sites.