How to add an image to a Beamer slide using a for loop in Quarto?

I have a the full path to three .png files saved to variable x

x = c(
"C:/Users/abc/fig1.png",
"C:/Users/abc/fig2.png",
"C:/Users/abc/fig3.png")

How do I create a new Beamer slide with the image from the given path and titled with the picture name, e.g., "fig1"? I tried the following Quarto code block, but it didn't work.

#| output: asis

for(p in 1:length(x)){
  title = str_split_fixed(x[p], "\.", n = 2)[1]
  cat(title)
  knitr::opts_chunk$set(fig.path=p)
}