Get relative path

Hello,

I use this to create the thumbnail, how to get the relative path (->url() ) to the thumbnail image ?

Why relative path ? because in my local environment the url adress to the vhost is like this: test.local/ without https / http.

	<section class="start flex grid-col-94 justify-content-spacearound">
		<?php
			$image = $pages->find('home')->cover()->toFile();
			$thumbURL = $image? $image->resize(2000)->url(): '';
		?>
		<div class="start-cover grid-col-74">
			<img src="<?php echo $thumbURL ?>">

		</div>
	</section>

Greetings

I’m not aware of a method to achieve that, but you could probably use the Url::path() method to get only the path to the file

dump(Url::path($image->resize(2000)->url()));

I tried this:

    <section class="start flex grid-col-94 justify-content-spacearound">
		<?php
			$image = $pages->find('home')->cover()->toFile();
			$thumbURL = $image? $image->resize(2000)->url(): '';
			$test = $image? dump(Url::path($image->resize(2000)->url())): '';
		?>
		<div class="start-cover grid-col-74">
			<img src="<?php echo $test ?>">

		</div>
	</section>

but the output is:

<img src="<pre>media/pages/home/2566963894-1551210935/start.jpg</pre>">

Well, the dump() method was only intended for debugging/ testing the output, not to be used in your src attribute.

I never used dump() because “ich nur an der Oberfläche von php kratze” :slight_smile:

What is the correct content of $test?

Well, let me turn the question round. What is the result you need?

This is the output: media/pages/home/2566963894-1551210935/start.jpg without the dump().

I can only recommend using dump() or var_dump() to inspect your results, it is “at the Oberfläche”, but still answers a lot of question and saves a lot of time.

it looks like that creating thumbnails locally does not work for me, does a special php module (apache) have to be activated?

What is your local environment? Do images work at all? Or are just the thumbnails not created?

Server version: Apache/2.4.29 (Ubuntu)
Server built:   2018-10-10T18:59:25

yes only the thumbnail creation do not work

Which Image library do you use, GD or IM?

Still, what is your local environment? Mamp? Built-in server? Valet?

Have you checked all our server requirements?

I do not set GD or IM so I think the default
for each website a vhost no mamp or other stuff

Well, is the GD library enabled?

Is the media folder writable?

Does the Panel work?

Apart from that, I’m running out of ideas.

when I trie to open the panel:

The session storage directory "/home/xxxxt/Schreibtisch/Pages/xxx.com/site/sessions" is not writable

are the file rights ok ?

The permissions look ok to me, provided that Ich is the Apache user, so the problem might be connected to ownership rather than permissions. Or you have to change the permissions, so that anybody can write.

This is not your first Kirby project, I’m wondering why you are running into these issues. Is that a new server setup you are not familiar with?

with kirby 2 I had no problems with the thumbnails,
so I think it has something to do with kirby 3.

But it is “1/2 so schlimm” because it works on the live server.

You could try to set your permissions to 775 or 777, probably not such a big deal locally, and test if that works.