I am stuck with live_img_preview from Programming LiveView book

Hi all,

I am stuck on this for weeks now and I cannot find my error. I am trying out uploading the images from Chapter 5 of the 'Programming Phoenix LiveView’.

I have tries the syntax in the book

<%= for image ← @uploads.image.entries do %> <.live_img_preview entry={image} width=“60” /> <% end %> 

as well as in the help

<.live_img_preview :for={entry ← @uploads.image.entries} entry=“{entry}” width=“60” /> 

but I always get the error

(FunctionClauseError) no function clause matching in Phoenix.Component.“live_img_preview (overridable 1)”/1 (phoenix_live_view 1.1.13) lib/phoenix_component.ex:3382: Phoenix.Component.“live_img_preview (overridable 1)”(%{entry: “{entry}”, id: nil, rest: %{width: “60”}, changed: nil, given: %{entry: “{entry}”, changed: nil}}) (phoenix_live_view 1.1.13) lib/phoenix_live_view/tag_engine.ex:109: Phoenix.LiveView.TagEngine.component/3 

Code is double and triple checked and contains

def update(%{product: product} = assigns, socket) do changeset = Catalog.change_product(product) {:ok, socket |> assign(assigns) |> assign_form(changeset) |> allow_upload(:image, accept: ~w(.jpg .jpeg .png), max_entries: 1, max_file_size: 9_000_000, auto_upload: true )} end 

What can be wrong?

Looks like you have =”{entry}” which should just be ={entry}.

1 Like

Cool, thanks a lot.

1 Like