Closed joernroeder closed 5 years ago
Do you have a specific setup? Does it happens with the upload hook or the button ?
I still probably lack understanding of k3's images behavior at this point, I don't understand how images would be prefixed with media
in an installation but not another.
@sylvainjule happens with the button in the panel. my folder structure is similar to the one in devkit https://github.com/k-next/devkit to keep everything except the entrypoint outside the domain root.
the media folder will be created in public
by kirby.
there is also the https://nnnnext.getkirby.com/docs/cheatsheet/roots/media function which should return the path
Thanks, I probably won't be able to take a look tomorrow but I will asap!
no problem, thanks!
@sylvainjule did you find some time to look into this? i would love to use it for a site which launches on monday. it would be a nice addition, nothing road blocking. no prob if you don't find some time, i'll stick with my current plan then… thx!
I'm having a look now but I can't reproduce this with a fresh devkit... colors are extracted as they should and no errors thrown.
Perhaps you could zip me a truncated version of your setup, changing the content if confidential, etc. so that I can debug on the correct folder structure?
Also could you screenshot me the response / error thrown ?
@sylvainjule responses from http://localhost:8000/plugins/colorextractor/process-image
are coming back with the following json:
{
"status":"error",
"error":"file_get_contents(\/media\/pages\/pageid\/myimage-300x200-q90.jpg): failed to open stream: No such file or directory"
}
for various reasons (reverse proxy, docker, ci) i had to set 'url' => '/'
in my config and i think therefore file_get_contents()
looks in server root. apart from not finding anything, this is also a potential security issue.
Ok thanks, with this config tweak I get the same error.
But since kirby has been told to rewrite its urls we can't rely on $kirby->url('media')
either as it returns the same prefix. Looking for a workaround.
The last commit fixes it for me.
(be careful though, I still need to set a cache for the plugin, I'm relying a lot on $site->index()
for now, if your website is content-heavy it might not like it)
just pretty quick:
But since kirby has been told to rewrite its urls we can't rely on $kirby->url('media') either as it returns the same prefix.
Url rewriting doesnt matter here imo as its about the absolute file system/disk path via $kirby->roots()
https://nnnnext.getkirby.com/docs/framework/cms/app/roots
My bad, within the new docs, what should have been $kirby->roots()->media()
is shown as $kirby->url('media')
, which returns the url of the folder, not its disk path.
Actually the better way would be to call $thumb->root()
or $thumb->mediaRoot()
, but I can't go with it right now as there is an issue with the $thumb object, this is why I went for url
. Probably best to wait for its fix than getting lost in quickfixes that will need to be changed in the end.
Yes, no need to rush here. Let’s wait. Thanks and enjoy the weekend!
Should be fixed, switched to root()
. ✅
Don't hesitate to reopen if not.
My image urls start with
/media/…
and the file is therefore not found. https://github.com/sylvainjule/kirby-colorextractor/blob/master/lib/functions.php#L9 could be prefixed with the media folder path from kirby->roots() but it's just a shot in the dark…