amp-img within amp-user-notification won't show on page load

324 Views Asked by At

I'm trying to add an icon into an amp-user-notification component. However, on page load, the amp-img doesn't show. If I scroll further down the page and refresh, the image loads. This also happens if I scroll down and then resize the screen.

I changed the layout type of the amp-user-notification to 'responsive' but that fails validation (due to not being an accepted type).

<amp-user-notification layout="nodisplay" id="event-bank-holiday" data-show-if-href="api/contactandhelp/get/event-bank-holiday" data-dismiss-href="api/contactandhelp/set/event-bank-holiday" data-persist-dismissal="false" class="alert theme--purple i-amphtml-element i-amphtml-layout-nodisplay amp-active" role="alert" i-amphtml-fixedid="F2" style="">
    <div>
        <span class="alert__icon">
            <span class="alert__icon__inner">
                <amp-img src="-/prefix/media/icons/alert-icons/bank-holiday.svg?h=40&amp;w=40&amp;hash=E3BFFD6190E698681D14FD8A35A0EE011B730964" width="40" height="40" alt="bank holiday icon" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined">
                    <i-amphtml-sizer style="padding-top: 100%;"></i-amphtml-sizer>
                 </amp-img>
             </span>
          </span>
     </div>
</amp-user-notification>

Code before front end render

<amp-user-notification 
    layout="nodisplay"
    id="event-bank-holiday"
    data-show-if-href="https://[...]/api/contactandhelp/get/event-bank-holiday"
    data-dismiss-href="https://[...]/api/contactandhelp/set/event-bank-holiday"
    data-persist-dismissal="false" class="alert theme--purple">
    <div>
        <span class="alert__icon">
            <span class="alert__icon__inner">
                <amp-img src="-/prefix/media/icons/alert-icons/bank-holiday-white.svg?h=40&amp;w=40&amp;hash=E3BFFD6190E698681D14FD8A35A0EE011B730964" width="40" height="40" alt="bank holiday icon" layout="intrinsic" />
            </span>
        </span>
    </div>
</amp-user-notification>
0

There are 0 best solutions below