I don’t think this is currently feasible. There are a couple of things going on.
style:
background: blue
works because when you use the style
property, you are using css and blue
is a valid css value for the background
property to have. On the other hand,
style:
background: =items.bgItem.state
doesn’t work for a few reasons.
- It doesn’t look like the
style
property of pages is processed through the expression parser, so you can’t use the same=expression
that you can use in the widgets; this means there’s simply no access to OH item states for the style properties of a page. - Even if you could access OH item states, the state of the OH image item is not a valid css value for
background
; when using an image for a background the typical format isurl(/path/to/image.file)
not the image itself. If I recall,url(raw image data)
will also work, but there’s another catch… - The state of an OH image is not the image data, but just a short MIME description such as
raw type (image/jpeg): 36930 bytes
the actual image data is stored in the rawState which I don’t think the widgetitems
object has any access to. So there’s just no way to pass the raw image data to the css styles of the page.
You might be able to find a workaround with a lot of effort. One possibility is an external file. There are threads here in the forum about saving the image of an image item to a file. If you saved that image with a consistent name in the $OH_CONF/html
folder, you could then statically link that file to the background property as:
style:
background: url(/static/name_of_image_file)
That would not update whenever the file changed, however, so you would have to also use something like:
and force the page to update whenever the image item changes.