Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Image width and height in flex object

Started by Josh Attwood 5 years ago · 1 replies · 584 views
5 years ago

I am having an issue with image width and height attributes.

In other areas of the site I am managing to get the width and height attributes of an image using something along the lines of:

TXT
page.media[item.image].width

However, when using images from the flex directory these attributes seem to not be possible.
The only data I am getting from these images is:

JS
array:1 [
  "user/data/flex-directory/files/kh3iX57SlARgw8u.jpg" => array:4 [
    "name" => "kh3iX57SlARgw8u.jpg"
    "type" => "image/jpeg"
    "size" => 31039
    "path" => "user/data/flex-directory/files/kh3iX57SlARgw8u.jpg"
  ]
]

I need to obtain the width and height of each image because of the way we are lazy loading the images in.

5 years ago

@joshattwood, Just a guess... What will you get if your do:

PHP
foreach( $images as $image ){
   page.media[$image['name']].width
}
last edited 11/14/21 by pamtbaau

Suggested topics

Topic Participants Replies Views Activity
Support · by TomW, 2 weeks ago
8 228 11 hours ago
Support · by alex, 2 months ago
8 667 1 day ago
Support · by Supple, 5 days ago
1 98 2 days ago
Support · by TomW, 1 week ago
3 160 3 days ago
Support · by TomW, 6 days ago
2 106 6 days ago