if-binding does not affect the entire element, but its contents. And since the img element has no content, binding does not matter.
This will work with span as container elements:
<span data-bind="if: $data"><img src="~/Images/yes.png" alt="oui" /></span> <span data-bind="ifnot: $data"><img src="~/Images/no.png" alt="non" /></span>
There is also syntax without a container if you do not want to add additional elements:
<img src="~/Images/yes.png" alt="oui" /> <img src="~/Images/no.png" alt="non" />
Fabian schmengler
source share