SVG Helper not working on live server

#1

Using the SVG helper to render a logo which works fine locally but not on my VPS (CentOS 7, Apache, PHP 7.2). I’m rendering it with the following…

<?php
  $logo = $site->sitelogo()->toFile()->mediaRoot();
  $logoalt = $site->sitelogoalt()->toFile()->mediaRoot();
?>

<?php if(!$page->isHomePage()): ?>
  <a href="<?= $site->url() ?>"><?= svg($logo) ?></a>
<?php else: ?>
  <a href="<?= $site->url() ?>"><?= svg($logoalt) ?></a>
<?php endif ?>

Is there anything wrong there? Does the helper depend on anything special, like php extension that might be missing?

I’ve had strange issues before with case sensitivity, maybe ->mediaRoot() is returning something it doesn’t like. Everything is lowercase though, so i’m not convinced that is the issue. It’s not even rendering the tag, nothing is getting rendered at all, just the anchor tag.

0 Likes

#2

Does the file exist in the media folder?

On a side note:

This sort of code is a no no…

0 Likes

#3

Why? the helper needs a filename & path, but the images are stored in fields, so yes they are in the media folder, they were uploaded through the panel. Whats the better way to do it?

0 Likes

#4

Because I’m preaching this here all the time: never to call an object method (mediaroot()) without checking for the object (the file in this case).

0 Likes

#5

Sure, but i know that :slight_smile: It’s a work in progress, I just haven’t written the check in yet.

0 Likes

#6

fine

So does

dump($logo)

return anything then?

0 Likes

#7

yes but can i DM you? I wont want to publicise the site. The dump is returning the right path and file name, but it is a full path from the server root, rather then from the web root. Maybe it doesn’t like that. I guess it cant start outside of the site folder for permissions reasons.

0 Likes

#8

Sure!

0 Likes

#9

Hm, it shouldn’t be a permissions problem, because PHP should be able to access parts outside the web root (otherwise this whole thing about putting stuff outside the web root wouldn’t work). If you don’t use the helper but do a simple

echo F::read($logo);

?

0 Likes

#10

Nope… that doesn’t work either.

0 Likes

#11

I just tried getting to the panel too and got this…

The panel assets cannot be installed properly. Please check permissions of your media folder.

But thats another problem.

0 Likes

#12

Maybe not, if the media folder is not readable, then files in the media folder wont be readable.

(And if you use the$file->root() instead of the mediaRoot?)

0 Likes

#13

I’m not sure how to fix that really, the files have the correct user:group etc. My other site does that. I know the media is writable because I exclude it from my rsync, and Kirby is generating images in the media folder, it just cant seem store the panel assets there.

0 Likes

#14

OK… that works! But it gives the same path back in a var dump that mediaroot() gave me… odd.

0 Likes

#15

As for this error, I just jumped on the server and deleted the media folder. Then i hit some pages, and kirby recreated the media folder and stored images in it. However, if i try hit the panel, i get the error above, its refusing to store the panel assets.

0 Likes

#16

I assume this is not the only project on your VPS, right? And all others are working without problems?

0 Likes

#17

My site (https://hashandsalt.com) and this site im working are the only K3 sites on the box. To be honest, i work locally and push up, i never work on the panel on the live site, so its not a huge deal. But i kind of feel the need to know why its not working. Both sites do it.

0 Likes

split this topic #18

6 posts were split to a new topic: Panel assets not stored in media folder - error

0 Likes