4

When I add a view.xml file to my theme I get the following error:

Exception #0 (Magento\Framework\View\Asset\File\NotFoundException): Unable to resolve the source file for 'frontend/Holy/mytheme/en_GB/Magento_Catalog/images/product/placeholder/.jpg' error message

I can fix it by uploading new product placeholder images on the Magento admin.

Is there another way to avoid this error? Why is this error occurring in the first place?

4
  • hope you able to fix this, Would you mind to put answer ? Wondering I've same issue with 2.3 version also :(
    – anonymous
    Commented Mar 17, 2020 at 8:45
  • It's a while back but I think this issue can also be fixed by adding the placeholder image to your theme, using a path to override it
    – Holly
    Commented Mar 17, 2020 at 8:48
  • So basically override these files github.com/magento/magento2/tree/… in your theme
    – Holly
    Commented Mar 17, 2020 at 8:52
  • No luck facing this in 2.3.3 :(
    – anonymous
    Commented Mar 18, 2020 at 18:33

2 Answers 2

4

In my case I had to add the requested image-format to my theme's view.xml file, for example:

<?xml version="1.0"?>    
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
        <media>
            <images module="Magento_Catalog">
                <image id="bundled_product_customization_page" type="thumbnail">
                    <width>140</width>
                    <height>140</height>
                </image>
    [...]
1

I have resolved this issue using below solution:

Please inject

\Magento\Store\Model\App\Emulation $appEmulation,

$sku = "my-sku";
// get the store ID from somewhere (maybe a specific store?)
$storeId = $this->storeManager->getStore()->getId();
// emulate the frontend environment
$this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true);
// load the product however you want
$product = $this->productRepositoryFactory->create()->get($sku);
// now the image helper will get the correct URL with the frontend environment emulated
$imageUrl = $this->imageHelperFactory->create()
  ->init($product, 'product_thumbnail_image')->getUrl();
// end emulation
$this->appEmulation->stopEnvironmentEmulation();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.