Open NyakudyaA opened 5 years ago
agreed - this also bothered me.
For training this is also really annoying. In general, there is almost no good reason to store absolute paths.
Just to add more on this I hand edited a project file to use relative path
I then proceeded to open the project in QGIS and then saved it in the database (PostgreSQL). Once it saved the project in the database It reverted to making the project use absolute path
I then opened a project from the database and saved it on disk to explore what was happening.
In my local computer, images are stored in the shared folder, monted on /mnt/dav
. On the server (QGIS Server), the same folder is /var/www/webdav/
.
It is not pretty (quite dirty workaround), but I use an expression for images, instead of the full path, like:
if (@user_account_name != 'jgr', '/var/www/webdav/', '/mnt/dav/') || 'images/Le_Corbusier_signature.png'
For a less dirty workaround, resources must be made available using a url, valid on the client side and on the server side.
In my setup (using webdav), users should copy their resources (images) to the shared folder on their computers. This images are immediately available through the server.
After copying the images, users must go to the browser to copy and paste the image's url to the composer.
I agree, in the meantime I'm sure something can be done as we have the @project_path variable available. Though path operations are not available with some string splitting and such, it should be doable.
For information, a way to fix this would be to make the call to canonicalFilePath
in this method optional based on such a things as the setting to save things in relative or absolute.
I agree, using relative path would be convenient.
A solution which is working well, to simulate a absolute path, you should use the data defined expression button with:
@project_home || '/picture.png'
which works well, whatever the OS (/
on Windows)
I agree, using relative path would be convenient.
A solution which is working well, to simulate a absolute path, you should use the data defined expression button with:
@project_home || '/picture.png'
which works well, whatever the OS (
/
on Windows)
When you store the project on a provider (Postgresql or Geopackage), this trick does not work. @project_home
will be empty.
Feature description. When creating layouts in QGIS a user can add images to the layout and the path to this is an absolute URL to where the image comes from ie
In the project file it is saved as an absolute path
This presents a lot of problems when the QGIS Projects are used with QGIS Server i.e in docker
If I mount the folder containing the project file and do a print request using the print layout the images are not found as I would have to edit the QGIS project to change the path