statamic / ssg

The official Statamic Static Site Generator
229 stars 23 forks source link

Images not being generated #103

Closed andylarkum closed 1 year ago

andylarkum commented 2 years ago

This is a recent issue (like, has only been a problem in the last couple of weeks).

Running php please ssg:generate isn't generating the image files for newly added content. Anything older than a couple of weeks ago is working fine, but anything added in the last couple of weeks fails to create.

For clarity, the local "live" version of the site works fine, the static version is missing the new images.

No idea where to start debugging this - any pointers/things I can try?

joshuablum commented 2 years ago

Hey @andylarkum,

What's the output of php please support:details? And what do your config files look like? Specifically config/statamic/assets.php & config/statamic/ssg.php

andylarkum commented 2 years ago

Hi @joshuablum

Thanks for getting back to me here. Results:

php please support:details says:

Laravel 8.83.17
PHP 8.0.19
cnj/seotamic 2.0.6
octoper/statamic-html-minify 0.0.5
pecotamic/sitemap 1.4.0
rias/statamic-redirect 2.3.6
statamic/ssg 1.0.1

confic/statamic/assets.php stripped of comments:

return [
    'image_manipulation' => [
        'route' => 'img',
        'secure' => true,
        'driver' => 'gd',
        'cache' => false,
        'cache_path' => public_path('img'),
        'presets' => [
            'xs-webp' => ['w' => 320, 'h' => 10000, 'q' => 85, 'fit' => 'contain', 'fm' => 'webp'],
            'sm-webp' => ['w' => 480, 'h' => 10000, 'q' => 85, 'fit' => 'contain', 'fm' => 'webp'],
            'md-webp' => ['w' => 768, 'h' => 10000, 'q' => 85, 'fit' => 'contain', 'fm' => 'webp'],
            'lg-webp' => ['w' => 1280, 'h' => 10000, 'q' => 85, 'fit' => 'contain', 'fm' => 'webp'],
            'xl-webp' => ['w' => 1440, 'h' => 10000, 'q' => 95, 'fit' => 'contain', 'fm' => 'webp'],
            '2xl-webp' => ['w' => 1680, 'h' => 10000, 'q' => 95, 'fit' => 'contain', 'fm' => 'webp'],
            'xs' => ['w' => 320, 'h' => 10000, 'q' => 85, 'fit' => 'contain'],
            'sm' => ['w' => 480, 'h' => 10000, 'q' => 85, 'fit' => 'contain'],
            'md' => ['w' => 768, 'h' => 10000, 'q' => 85, 'fit' => 'contain'],
            'lg' => ['w' => 1280, 'h' => 10000, 'q' => 85, 'fit' => 'contain'],
            'xl' => ['w' => 1440, 'h' => 10000, 'q' => 95, 'fit' => 'contain'],
            '2xl' => ['w' => 1680, 'h' => 10000, 'q' => 95, 'fit' => 'contain'],
        ],
    ],
    'auto_crop' => true,
    'thumbnails' => [
        'max_width' => 10000,
        'max_height' => 10000,
    ],
    'google_docs_viewer' => false,
    'cache_meta' => true,
];

...and config/statamic/ssg.php:

return [
    'base_url' => config('app.url'),
    'destination' => storage_path('app/static'),
    'copy' => [
        public_path('css') => 'css',
        public_path('js') => 'js',
        public_path('assets') => 'assets',
        public_path('fonts') => 'fonts',
    ],
    'symlinks' => [
        // public_path('css') => 'css',
        // public_path('js') => 'js',
    ],
    'urls' => [
        '/posts',
        'sitemap.xml',
        'robots.txt'
    ],
    'exclude' => [
        //
    ],
    'glide' => [
        'directory' => 'img',
    ],
    'failures' => false, // 'errors' or 'warnings'
];
joshuablum commented 2 years ago

Thanks for providing those details! Config looks fine to me.

What's interesting: Someone else that ran into this issue (or at least very similar) was also on Laravel 8 and PHP 8.0. If it's not too much work, could you try upgrading to Laravel 9 and PHP 8.1?

andylarkum commented 2 years ago

OKey doke

I've updated to Laravel 9 and PHP 8.1, regenerated and re-synched to AWS S3. Now just need for cloudfront to update :)

I'll update soon...

A.

andylarkum commented 2 years ago

Nope

Still no images.

Stumped

joshuablum commented 2 years ago

Thanks for the update and for upgrading to Laravel 9 and PHP 8.1!

Are you running the plain php please ssg:generate command or are you also passing the --workers argument to it? If you're using workers, could you try to run it without them.

andylarkum commented 2 years ago

Yup, just generate, no workers

jasonvarga commented 2 years ago

Where are you running the ssg:generate command? On production? Locally?

~If you run php artisan cache:clear before ssg:generate, do the new images appear?~

I think if you clear your Glide cache (using php please glide:clear), the images should appear next time you generate the site.

andylarkum commented 2 years ago

Hi @jasonvarga Running ssg:generate on local

I discovered that I have to run php please cache:clear before AND after ssg:generate, otherwise

  1. generate fails; and
  2. the local site errors afterwards

...but, perhaps I'll get a different result with php artisan cache:clear?

globalexport commented 1 year ago

Hi @andylarkum,

Are the images physically missing in the generated folder, or do you maybe experience the same behaviour in HTML I found with using the spatie responsive image plugin after the update: https://github.com/spatie/statamic-responsive-images/issues/146

andylarkum commented 1 year ago

Hi all

@globalexport and @jasonvarga - my apologies for not replying sooner. Composer broke - and I've not been able to resolve it yet (throw in a holiday for delay!)

In case anyone cares, composer error is: PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.14.

...which is very annoying, as I've apt remove'd all other versions of PHP other than 8.1!

Anyways, I'm believing that the #146 solutions will have solved it once I can get sail up and running again...