If you want to produce html table code to use with knitrExtra afterwards, you need to take care of escaping.
By default, knitr::kable() will escape special character so that they print correctly in the HTML table. In your case, you don't want that, because you put in your table some html code directly, so you want it as is.
There is an option for that:
knitr::kable(tab, format = "html", escape = FALSE)
With this, no escaping will happen. See the doc for details.
The < and > of your html code for image won't be escape anymore and this should work.