Add support for allocated height for inline images

This commit is contained in:
Hypolite Petovan 2023-09-23 22:43:31 -04:00
parent 86141eb363
commit c4657c4661
2 changed files with 32 additions and 8 deletions

View file

@ -1164,4 +1164,21 @@ class Media
}
return $url . $id;
}
/**
* Computes the allocated height value used in the content/image.tpl template based on a post-media record
*
* @param array $media A post-media record array
* @return string
*/
public static function getAllocatedHeightByMedia(array $media): string
{
if (!empty($media['preview-height'])) {
$allocated_height = (100 * $media['preview-height'] / $media['preview-width']) . '%';
} else {
$allocated_height = (100 * $media['height'] / $media['width']) . '%';
}
return $allocated_height;
}
}