I'm trying to update an old plugin to QGIS3 where we use default svg files (in the plugin folder) as markers. It is important that it is the plugin folder since I just to have the entire plugin in one location.
In QGIS2.18 I could specify the path to the svg marker as: :/PLUGIN_NAME/IMAGE_FOLDER/FILENAME.svg
Update:
I use an .sld file to specify the .svg path (and other attributes like name etc.) The
<se:OnlineResource xlink:type="simple" xlink:href=":/PLUGIN_NAME/IMAGE_FOLDER/FILENAME.svg"/>
When I try it now in QGIS3 I just gets ?
instead of the svg symbol, unless I use absolute paths to the plugin and the image folder :(
Update:
I tried to add %AppData%/QGIS/QGIS3/profiles/default/python/plugins
in front of PLUGIN_NAME
, hence without success.
The .qgs file is used in multiple computers, so I want to specify a relative path in the .sld files
to the svg file.
Any suggestions how to write it in QGIS3?
self.plugin_dir = os.path.dirname(__file__)
, could you try using<se:OnlineResource xlink:type="simple" xlink:href=self.plugin_dir + "/IMAGE_FOLDER/FILENAME.svg"/
<se:OnlineResource....
is in the .sld file and not inmain.py
(self.plugin_dir
isn't available). If I look at the path in QGIS it gives meself.plugin_dir/PLUGIN_NAME/IMAGE_FOLDER/FILENAME.svg
with that suggestion.