Description
Description
I've been trying to create an extension with an entity that has an image attribute. I want to show on frontend the resized image similar to how the product image is resized in the product list page.
For this I've created image model and helper and the builder block.
The resize works perfectly if I specify the width and height (and other attributes) in the template file when calling $block->getImage(....)
.
But I wanted to do it properly and read the resize values from the view.xml
file
Then I created a file called etc/view.xml
and every page crashes
Steps to reproduce
Create a file called etc/view.xml
in any module with this content
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
<media>
<images module="Namespace_Module"><!-- the module attribute can be anything other than Magento_Catalog -->
<image id="whatever_here">
<width>60</width>
<height>60</height>
</image>
</images>
</media>
</view>
Expected result
I should be able to read my values using Magento\Framework\View\ConfigInterface::getViewConfig()::getMediaAttributes('Namespace_Module', 'image', 'whatever_here')
Actual result
Every page crashes because the merged view.xml
files apparently are not valid.
The error message is
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid Document
Element 'images': This element is not expected.
Line: 22
Line 22 in my file is <images module="Namespace_Module">
Additional info:
Changing Namespace_Module
to Magento_Catalog
makes the error go away, but then again I cannot have a configuration for my module.