Open BernhardBaumrock opened 5 years ago
Note: this doesn't seem like an issue, so seems like a better fit for the processwire-requests repository.
True, thx @teppokoivula and @netcarver 👍
I think $config->path() and $config->url() would even be a better choice (without the S) - edited the headline
Hey @ryancramerdesign once more this is really painful for me:
Im returning preview images (JPG) for files in a files field (PDF), where $preview
holds the file PATH to the JPG. I need the path to check if the file exists, but I need the URL for the <img>
tag to define the src
attribute:
Having a $config->url($path)
API method would make this a lot easier and straightforward:
I've just added a PR for this request: https://github.com/processwire/processwire/pull/210
Short description of the issue
I find myself very often converting paths to urls and vice versa. For example today I had to deal with it when using MPDF library and file field items.
Expected behavior
It would be great to have an easy and fool proof solution to convert relative urls to paths and paths to relative urls.
Actual behavior
At the moment we need to do complicated string concatenations that are even error prone (for example when one does not think of different directory separators on different platforms or installations in subfolders). See my related PR here: https://github.com/processwire/processwire/pull/143
Examples of possible API implementation