Path to assets broken after uploading to webserver

Hi
I’m still messing around with Kirby :slight_smile:

Locally I run Kirbys server: php -S localhost:8000 kirby/router.php
Everything is fine when testing it locally.

But after uploading all files to the hosting-webserver, the path to the assets is broken.
Kirby does not recreate the asset-files in /media.

Example:
Project-Logo-File, locally:
http://localhost:8000/media/site/c60d70679b-1624237861/projekt-logo-start.svg

Same file after uploading all files to a blank hosting-webserver-directory:
https://test.mydomain.ch/media/site/f72ef4e0c1-1635248335/projekt-logo-start.svg
(/media/site/f72ef4e0c1-1635248335/projekt-logo-start.svg does not exist on the server)

Edit:
When I delete /media on the webserver, then only “pages” get recreate, but not images and so on.

Any idea what I do wrong?

Kind regards
Alain

Don’t upload the media folder, it is basically a cache folder. It should get recreated automatically on the server. If it doesn’t, check your file/folder permissions.

Deleting the media-folder on the web-server didn’t help.
Permissions of which files/folder do you mean an what permissions should they have?

Hm, which thumb driver are you using? (Although svgs are not resizable and should be copied to the media folder independent of whether the driver works or not).

What is a thumb driver?
And where can I find it?

The /site/config/config.php does not contain anything about thumbs.
But why should I care about it, isn’t it a task of Kirby?
Why should there be a difference between my local server and the web-server?

By default, Kirby uses the GD library for manipulating images, but you can also use other like imagemagick or even custom ones.

It’s possible to have issues with this library on your server (local or remote), hence the question.

But in this case I should get an error-message on the web-server - no?

I just added this to /site/config/config.php

'thumbs' => [
    'driver' => 'im',
    'bin' => '/usr/local/bin/convert'
]

But it does not help.
File/folder permission should be ok because after deleting /media it gets recreated (but only for pages not for images).

Any other idea?

Is ImageMagick even installed on the server? Simply enabling it in the config will not help.

That probably means that the parent folders for the images are created. What about the .jobs folders and the .json job files for thumbs insides those folders? Are they created?

Having said that, an .svg file is not resizable, so the thumb driver should not be involved at all, but the file should simply be copied into the media folder.

Could you try the following e.g. in the home template on your server:

<?php

$file =  $site->image(); // here I use the first image in the site, you can replace this with any other file.
Kirby\Cms\Media::publish($file, $file->mediaRoot());
?>

Then reload the home page in the browser.

With this example, you should get a copy of the site file in `/media/site/xxx-xxx/filename.

<?php

$file =  $site->image(‘projekt-logo-start.svg’); // here I use the first image in the site, you can replace this with any other file.
Kirby\Cms\Media::publish($file, $file->mediaRoot());
?>

The above code snippet works, the ‘projekt-logo-start.svg’ file shows up.
But what to do to show all the remaining images?

And yes .jobs folders have been created before and there are .json files in it.

And when you delete the file in the file copy in media folder again and replace the above example code with

<?php echo $site->image(‘projekt-logo-start.svg’)->url() ?>

Is the file then recreated?

No, it only outputs the path on the frontsite.

Hm, which Kirby version are you using? Are you using any custom code (third party plugins, own extensions, models etc.)?

Kirby 3.5.6.
Yes there are plugins:
phpspreadsheet
TCPDF

And a helper plugin (from you) for kirbytext raw

function ktRaw($content) {
  $text = kirbytext($content);
  return preg_replace('/(.*)<\/p>/', '$1', preg_replace('/<p>(.*)/', '$1', $text));
}

field::$methods['ktRaw'] = function($field) {
  return ktRaw($field->value);
};

And yes some own models, controllers, …

Since it seems to work localhost: What are the differences between you local setup and the remote server? Where are you hosting the site? When you update to the current 3.5.7.1 version, does the issue persist?

You could also try and upload a fresh (up-to-date) Starterkit to the server to find out if that works without issues.

1 Like

I tried now with Git by creating a remote repository on the hosting server instead of just copy the files to the server.
Now it works :slight_smile:
I have no idea what I have done wrong before :thinking:

Anyway, thanks for your patience and ultrafast, kind support!