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:
"} + {"arg":"property", "description":"a string corresponding to the property to return. Valid options are:
"} ], "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" ) ); + } + } } }