Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Get width and height from media svg

Started by Muut Archive 9 years ago · 2 replies · 536 views
9 years ago

Hello

I try to get height and width from svg media file, image_width return null but when el_footer_logo is png or jpg it return correct value.

TWIG
{# LOGO #}
{% set el_footer_logo = page.header.el_footer_logo %}
{% set image_width = page.media[el_footer_logo].width %}
{% set image_height = page.media[el_footer_logo].height %}

Maybe be i miss something or maybe it's an issue.

9 years ago

I imagine this would depend on the .svg, as they do not necessarily have an explicit width set initially. By nature they are vector-files, so size is irrelevant, and I think the image-processing back-end (Gregwar) checks file metadata for this - which for a .svg would as you note, return null, because it is only set through HTML-attributes and are generally considered superfluous (control .svg-size through CSS, not HTML).

9 years ago

@OleVik yes you're right, it make sense, thanks a lot

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1341 9 years ago
Archive · by Muut Archive, 9 years ago
2 928 9 years ago
Archive · by Muut Archive, 9 years ago
2 4057 9 years ago
Archive · by Muut Archive, 9 years ago
1 2942 9 years ago
Archive · by Muut Archive, 9 years ago
3 1115 9 years ago