Copy Media Folder to Server

Thanks for your fast reply!

You could replace the hash with something static, then it should work. You will loose automatic cache invalidation that way though.

This is actually what I did now. As far as I understand it, the hash is in part ‘generated’ by the modified date of the file and this date is different in the local environment and the server. I changed that part to be ‘generated’ by the filename. I changed some files in the kirby folder. It doesn’t feel right to do so, but I don’t know another way.

There is another thread (Adjusting the media hash generation) which led me to those files.
Idk whether its a good idea to share my code since its probably really bad, but it seems to work for me.

/kirby/src/cms/app.php

public function contentToken(object|null $model, string $value): string
{
	if ($model !== null) {
		return hash_hmac('sha1', $model->name(), 'foo');
	}

	return hash_hmac('sha1', $value, 'foo');
}

(I think $model might be the file object and $value might be some related data)

/kirby/src/cms/file.php

public function mediaHash(): string
{
	return $this->mediaToken() . '-' . '1';
}

(I left both ‘-’ and ‘1’, since the thumbs job of the janitor plugin has a regex to find all .jobs in the media folder and it searches for those types of characters. Otherwise there is no reason for leaving them there.)

Now the hashed folders are always the same, both locally and on the server. Which means that I can generate all thumbs locally and upload them to the server, which is of course not the most elegant way, but as I said, I somehow have issues with generating AVIF files on the server.

Don’t you use Kirby as a CMS then or only locally and not on the server? Otherwise, if you add images on the server, the thumb won’t be generated either?

I’m going to use Kirby as a CMS both locally and on the server. But the server will just be an exact mirror of the local version.

How about moving to another hosting provider?

Yes, you are right, maybe another hosting provider might be worth thinking about, or at least another plan where I can install my own instance of ImageMagick etc.

If you have any suggestions for a more thorough approach than the above, I’d be happy to hear about it! But thanks a lot already!