Reading global resources from page parameters

Dear all,

I’m trying to import an image from global resources using a page parameter (see figure for reference).

In the current code, I am using “with” to avoid throwing an error when a page does not have the “background” parameter, but neither GetMatch nor Get seem able to load the file specified in .Params.Background

I’m sure the directory in the config.toml is correct, since resources.Get works fine if I just pass the file directory. It doesn’t work only when I’m passing it as a parameter, in any way you suggested in previous replies…

Can anyone tell me what I am doing wrong?

Thanks,

Dave

Use lowercase: .Params.background

Page-level .Params are only accessible in lowercase.


EDIT: looks like you also have variable re-assignment problem. $image should use =

{{ $image = resources.GetMatch $path }}
1 Like

Oh, now I got it!
It wasn’t a matter of lowercase or uppercase, but the second tip helped!

Thank you very much for your super-quick reply!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.