diff --git a/resources/function_help/json/layer_property b/resources/function_help/json/layer_property
index f6c33d482fe..df547bdde6a 100644
--- a/resources/function_help/json/layer_property
+++ b/resources/function_help/json/layer_property
@@ -4,7 +4,7 @@
"description": "Returns a matching layer property or metadata value.",
"arguments": [
{"arg":"layer", "description":"a string, representing either a layer name or layer ID"},
- {"arg":"property", "description":"a string corresponding to the property to return. Valid options are:
- name: layer name
- id: layer ID
- title: metadata title string
- abstract: metadata abstract string
- keywords: metadata keywords
- data_url: metadata URL
- attribution: metadata attribution string
- attribution_url: metadata attribution URL
- source: layer source
- min_scale: minimum display scale for layer
- max_scale: maximum display scale for layer
- crs: layer CRS
- crs_definition: layer CRS full definition
- crs_description: layer CRS description
- extent: layer extent (as a geometry object)
- type: layer type, e.g., Vector or Raster
- storage_type: storage format (vector layers only)
- geometry_type: geometry type, e.g., Point (vector layers only)
- feature_count: approximate feature count for layer (vector layers only)
"}
+ {"arg":"property", "description":"a string corresponding to the property to return. Valid options are:
- name: layer name
- id: layer ID
- title: metadata title string
- abstract: metadata abstract string
- keywords: metadata keywords
- data_url: metadata URL
- attribution: metadata attribution string
- attribution_url: metadata attribution URL
- source: layer source
- min_scale: minimum display scale for layer
- max_scale: maximum display scale for layer
- crs: layer CRS
- crs_definition: layer CRS full definition
- crs_description: layer CRS description
- extent: layer extent (as a geometry object)
- type: layer type, e.g., Vector or Raster
- storage_type: storage format (vector layers only)
- geometry_type: geometry type, e.g., Point (vector layers only)
- feature_count: approximate feature count for layer (vector layers only)
- path: File path to the layer data source. Only available for file based layers.
"}
],
"examples": [
{ "expression":"layer_property('streets','title')", "returns":"'Basemap Streets'"},
diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp
index 6049191c7e0..61a3c794dec 100644
--- a/src/core/expression/qgsexpressionfunction.cpp
+++ b/src/core/expression/qgsexpressionfunction.cpp
@@ -4025,6 +4025,14 @@ static QVariant fcnGetLayerProperty( const QVariantList &values, const QgsExpres
return QgsWkbTypes::geometryDisplayString( vLayer->geometryType() );
else if ( QString::compare( layerProperty, QStringLiteral( "feature_count" ), Qt::CaseInsensitive ) == 0 )
return QVariant::fromValue( vLayer->featureCount() );
+ else if ( QString::compare( layerProperty, QStringLiteral( "path" ), Qt::CaseInsensitive ) == 0 )
+ {
+ if ( vLayer->dataProvider() )
+ {
+ const QVariantMap decodedUri = QgsProviderRegistry::instance()->decodeUri( layer->providerType(), layer->dataProvider()->dataSourceUri() );
+ return decodedUri.value( QStringLiteral( "path" ) );
+ }
+ }
}
}