Skip to content

Cannot create a etc/view.xml file with an images tag with an attribute module other than Magento_Catalog #5381

Closed
@tzyganu

Description

@tzyganu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendFixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions