Magento 2 KnockoutJS – Render Image Using KnockoutJS

knockoutjsmagento2

/**
     * @return array
     */
    protected function getItems()
    {
        $items = [];
        foreach ($this->helper->getItemCollection() as $item) {
            $items[] = [
                'id' => $item->getId(),
                'product_url' => $this->productUrl->getUrl($item),
                'name' => $this->outputHelper->productAttribute($item, $item->getName(), 'name'),
                'image' => $this->outputHelper->getProductImageUrl($item),
                'remove_url' => $this->helper->getPostDataRemove($item),
            ];
        }
        return $items;
    }

$this->_itemCollection->addAttributeToSelect('image')->addUrlRewrite()->load();

<img data-bind="attr: {'src': image}"/>

Best Answer

Please check below link

https://stackoverflow.com/questions/10659665/knockout-template-using-data-bind-to-image-src-property-not-working

otherwise check Magento\Checkout\view\frontend\web\template\summary\item\details\thumbnail.html

Related Topic