# Get relative path

**URL:** <https://forum.getkirby.com/t/get-relative-path/13148>\
**Category:** Questions\
**Tags:** v3\
**Created:** [March 2, 2019, 1:20pm UTC](https://forum.getkirby.com/t/get-relative-path/13148 "2019-03-02T13:20:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 1:20pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/1 "2019-03-02T13:20:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 2:43pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/2 "2019-03-02T14:43:43Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 3:27pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/3 "2019-03-02T15:27:03Z")

</div>

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>">`

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 3:34pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/4 "2019-03-02T15:34:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 3:52pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/5 "2019-03-02T15:52:05Z")

</div>

> [@texnixe](#):
>
> dump(Url::path($image-\>resize(2000)-\>url()));

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

What is the correct content of $test?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 3:53pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/6 "2019-03-02T15:53:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 4:18pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/7 "2019-03-02T16:18:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 4:33pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/8 "2019-03-02T16:33:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 4:45pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/9 "2019-03-02T16:45:52Z")

</div>

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

```

yes only the thumbnail creation do not work

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 4:47pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/10 "2019-03-02T16:47:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 4:50pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/11 "2019-03-02T16:50:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 5:26pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/12 "2019-03-02T17:26:52Z")

</div>

Well, is the GD library enabled?

Is the media folder writable?

Does the Panel work?

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

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 8:36pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/13 "2019-03-02T20:36:40Z")

</div>

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 ?

 ![Bildschirmfoto%20vom%202019-03-02%2021-33-32](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/d/d5145a7c30d3e4260797dc3482ec7b34bbbfaa5b.png)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 8:54pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/14 "2019-03-02T20:54:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [March 2, 2019, 10:05pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/15 "2019-03-02T22:05:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 2, 2019, 10:29pm UTC](https://forum.getkirby.com/t/get-relative-path/13148/16 "2019-03-02T22:29:35Z")

</div>

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