I'm new to Blazor - so this may be obvious but I can't figure it out. I have a WebAssembly project and a separate Razor Class Library where I have some components. I have a component that I want an image in - I place the image in the wwwroot/img folder of the library and access as below
<img src="/img/logo.png" alt="test logo" />
But it will not display - I've tried
<img src="_content/img/logo.png" alt="test logo" />
But it won't display either.
The only way I can get my image to display is to put it into the wwwroot/img folder of the Client Project. But I want my component library to be able to be used in other projects.
Any guidance much appreciated. I'm coming from a Windows Forms background so I have a lot to learn :)
I´m also new to web development, but afaik the wwwroot folder serves as folder for static files your webpage uses (this is also the only folder the browser can access for media files for security reasons as I have understood it).
I had the same problem some days ago, I solved it by putting everything into the wwwroot folder, but I also found an article in which another way is suggested.
http://blog.vivensas.com/static-image-in-blazor-inside-and-outside-web-root/
There it is basically suggested to create a method in the Startup.cs file, which will be able to get your images from elsewhere:
Then you can use your images like this:
Edit: Maybe I misunderstood your question, for this to work it also has to be in the client project. I don´t know the way to get images from other solutions than the client project.