#2706663: Use amp-img for site branding logo properly uses amp-img for the logo in the branding block. However if the logo is an SVG, the height and width are empty because Drupal's image library cannot obtain that info from an SVG. We may be able to manually parse the SVG file to get the height and width from the ViewBox.

Note that the width and height attributes on an SVG are not terribly reliable since they can contain units, so are more difficult to parse. Checking the width and height of the ViewBox may not support all SVGs, but it supports more than now.

Comments

mdrummond created an issue. See original summary.

rainbowarray’s picture

Tried this code both with and without an SVG for the logo. Seems to work fairly well.

  • mdrummond committed ee72071 on 8.x-1.x
    Issue #2707439 by mdrummond: Parse SVG ViewBox for width and height of...
rainbowarray’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.