Grav: Grav not creating images in cache

Created on 18 Dec 2016  路  12Comments  路  Source: getgrav/grav

I'm running Grav on shared hosting. I'm using some filters on images, so I expect the rendered images to be created in the images/ folder and referred to in the rendered HTML.

This doesn't happen. Instead, the HTML refers to f/a/l/l/b/fallback.jpg, which is a red error image. This image is saved in the images/ folder and is recreated after I delete it, which is why I don't think it is a problem with permissions. Grav also has no problem creating files in the cache/ directory.

I have developed the site locally, using a VM with Apache installed, and when I copy my local cache over to the shared hosting, everything works perfectly. As soon as I clear the cache on the shared hosting, however, Grav seems to be unable to recreate the images in the cache.

Since it's on shared hosting, I don't have access to the system wide PHP log. I have added the following to .htaccess to gain access to the log anyway:

php_flag log_errors on
php_value error_log <location of log file>

I have tested that this works by creating a test script that calls error_log. These calls are correctly logged in my log file. The log never contains any errors from Grav, though.

The shared hosting allows me to select which PHP version to use. I have tried PHP 5.5.9 and 5.6.23, both give the same behaviour. All the required modules (gd, curl, openssl, zip, mbstring, xml) are installed. I have also tried PHP 7.0.12 but then the entire site breaks. PHP 7 also breaks a WordPress site running on the same shared hosting so there's probably something else wrong there.

Do you have any idea what could be causing my problem?

question

All 12 comments

It could be an issue with the GD library on the server.

Run the Problem plugin on the server. That plugin is usually installed but it's only ran the first time you open Grav, then it creates a cache/problem-check-* file. Delete that file, and the plugin will run its check on the server too.

The Problem plugin was installed. I deleted the cache/problem-check-* file and opened the site again. That gave me a new file cache/problem-check-g-0c166db8 which is empty.

Ok so the checks are passed.

I noticed an older similar issue caused by libpng support missing in the server config. Could this be the case?

phpinfo() says the following under the gd heading:

PNG Support enabled
libPNG Version  1.2.50

My pictures are actually jpegs.

JPEG Support    enabled
libJPEG Version 8

I have tried some more things.

I have a working site on the www subdomain. This site also recreates the images in the cache when the cache is cleared.

When logged in using SSH, I copied the working site over to the staging subdomain, which was giving me errors until now. I cleared the cache and visited the site. This also works.

Then, I ran my automatic deploy over SFTP to the staging subdomain. This updates all files but does not remove any files. So, after this deploy _the cached images still exist_. When visiting the site I now get the large red error message, though.

I have the feeling that the transfer via SFTP is messing things up. I can imagine, for example, that certain files need to have execute rights and that the SFTP transfer doesn't set those correctly. Could this be the case?

Logging into the server using SSH and pulling using git clone gives the same issues. Only uploading the files directly using WinSCP and SSH seems to work. I don't want to store my SSH key on an untrusted server, though, so using this for automatic deploys is not really an option. @flaviocopes, do you have any clue?

Hi @EmielH and @flaviocopes ,

Did you find any solutions for this problem? I have the same problem on Digital Ocean. GD is already installed an enabled so I have no ideas what could cause this.

GD Support enabled
GD Version bundled (2.1.0 compatible)
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.2.49
WBMP Support enabled
XBM Support enabled

@tranduyhung Unfortunately I haven't been able to fix this problem. I've given up on updating the site automatically and upload the files manually using WinSCP and SSH now.

You might want to check if files in the cache are using the right permissions: https://learn.getgrav.org/troubleshooting/permissions#cache-folder-permissions

Same thing here , i did make sure that the cache permissions are ok but it did not fix the issue. I'm using nginx and php 7.1 on alpine

I have solved my problem. In my case, the problem had nothing to do with Grav. The images were stored as text in the Git repository, which corrupted them upon push because CR/LF bytes were changed. Committing them again as binary has solved the problem for me.

My client said their server administrator fixed this problem by upgrading PHP to the newest version which Digital Ocean had. Because I don't have communication with the administrator guy so I don't have any other information. I don't remember what the old PHP version was, but I am sure Grav is compatible with it, everything was working well except image caching. It seems the problem was between PHP and GD library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fvsch picture fvsch  路  3Comments

marcastel picture marcastel  路  4Comments

philipisik picture philipisik  路  4Comments

tdulieu picture tdulieu  路  3Comments

vico93 picture vico93  路  5Comments