Files


$image Properties (in addition to those in $file)

$image->height

Introduced in Version 2.0

Description

Height of image, in pixels

Using image height inside img tag:

// Grab the first image from images-field
$img = $page->images->first();

// Echo it with width and height like we did in 90's 
echo "<img src='$img->url' alt='' width='$img->width' height='$img->height' />";

The height-property can be used in other situations too, for example inline CSS:

// Echo some css where .header is same height as the image
echo "<style> .header { height: {$img->height}px; } </style>";

Post Comment