Skip to content

Is it possible to pass images/image urls as properties #5054

Answered by ogoffart
Kyr27 asked this question in Q&A
Discussion options

You must be logged in to vote

Basically you cannot convert a string to an image or an image to a string.
So this means that you need to have it marked as an image and not a string.

Your Sidebar class probably has a

in property <[{text: string, imageUrl: string}]> model;

But it imageUrl shouldn't be a string, it should be an image, like so:

in property <[{text: string, imageUrl: image}]> model;

Then this should work:

{ text: @tr("Menu" => "placeholder"), imageUrl: @image-url("./icons/image-placeholder.svg")}

(imageUrl might not be the right name for it since the field is really an image and not its URL.)

I hope this helps.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Kyr27
Comment options

Answer selected by Kyr27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants