mirror of
https://github.com/friendica/friendica
synced 2025-04-27 00:30:10 +00:00
Add support for allocated height for inline images
This commit is contained in:
parent
86141eb363
commit
c4657c4661
2 changed files with 32 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue