Hello, so I’m trying to load images using the username of each post as part of the route where the profile pictures are, basically it’s this format.
assets/profilepics/username.png
I tried doing it like this <img src=“static_path(@conn, “/assets/profilepics/#{@posts.user.name}.png”) %>”></img>, but it didn’t do the trick. What would be the correct way to add the username to the section of the tag that requires it?
In my code as well, I tried doing it with <%= as well but it still shows up as a broken image. And no error per se, just the broken image icon instead of the image in the path.
Also, I do show the user name in one of the posts sections, and it’s loaded fine, so the path not loading fine has to do with my syntax for the img src tag. I’m just not sure where, this is my first project with Phoenix/elixir and I’ve been having some troubles with syntax/logic while working on it.
And how exactly does the code look like that generates this error and the wrong output? The first output clearly shows you are not using <%=, the error shows you are using it probably wrong.
Sweet! That did it. Now the HTML looks like this <img src="/assets/profilepics/pmgbove.png">, still shows up a broken image icon but I’ll figure that one out. Thanks a lot!