Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tzyganu opened this issue Jun 30, 2016 · 6 comments
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@tzyganu
Copy link
Contributor

tzyganu commented Jun 30, 2016

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.

@nicolaspernot
Copy link

Same problem here. I will try to find time for propose a pull request in (near?) future.
Problem comes from the Config/etc/view.xsd.

Just change this part:

<xs:complexType name="mediaType" mixed="true">
        <xs:all>
            <xs:element name="images" type="imageType" minOccurs="0"/>
            <xs:element name="videos" type="videoType" minOccurs="0"/>
        </xs:all>
    </xs:complexType>

by:

<xs:complexType name="mediaType" mixed="true">
        <xs:sequence>
            <xs:element name="images" type="imageType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="videos" type="videoType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

And that seems solve the problems.

@adragus-inviqa
Copy link
Contributor

Confirmed. Can someone get the ball rolling on this one, please? Mark it up for grabs or something, for visibility.

@SiarheyUchukhlebau
Copy link

Any news about when this bug can be fixed?

@tzyganu tzyganu mentioned this issue Jun 26, 2017
4 tasks
@tzyganu
Copy link
Contributor Author

tzyganu commented Jul 13, 2017

I see that the PR for this was accepted. Can I close the issue?

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-70256

@magento-team magento-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report develop Area: Frontend labels Jul 31, 2017
@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report develop Area: Frontend Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@tzyganu @ajpevers thank you for your report.
The fix for this issue is already available in release 2.2.0

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Sep 20, 2017
magento-engcom-team pushed a commit that referenced this issue Feb 25, 2020
[TSG] Fixes for 2.4 (pr13) (2.4-develop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

8 participants