Image component not displaying in Vaadin Flow application

816 views Asked by At

I have a view in my Vaadin Flow Application called HomeView. I am attempting to add an Image component called logo.png to this view to display it on the home page. The code for HomeView looks like so:

package ymca.tracker.application.views.home;

import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

@PageTitle("Home")
@Route(value = "home")
public class HomeView extends VerticalLayout {

    public HomeView() {
        setSpacing(false);

        add(new H2("Welcome!"));
        add(new Image("frontend/images/logo.png", ""));

        setSizeFull(); setJustifyContentMode(JustifyContentMode.CENTER);
    setDefaultHorizontalComponentAlignment(Alignment.CENTER);
    getStyle().set("text-align", "center");
    }
}

I have verified the file path is correct as well as the name and type of the file. I have tried adding alternate text but the image still does not display. Currently, an icon is emplaced instead of the actual image I want displayed. See below:

enter image description here

I've tried directly placing the file in the frontend folder as well, with no luck either. Not sure what the issue could be here as this seems pretty straightforward.

0

There are 0 answers