mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:12:25 -05:00
[feature] Update attachment format, receive + send focalPoint prop + use it on the frontend (#4052)
* [feature] Update attachment format, receive + send `focalPoint` prop + use it on the frontend * whoops * boop * restore function signature of ExtractAttachments
This commit is contained in:
parent
6a6a499333
commit
f7323c065a
18 changed files with 617 additions and 72 deletions
|
|
@ -136,6 +136,7 @@ func LoadTemplates(engine *gin.Engine) error {
|
|||
var funcMap = template.FuncMap{
|
||||
"add": add,
|
||||
"acctInstance": acctInstance,
|
||||
"objectPosition": objectPosition,
|
||||
"demojify": demojify,
|
||||
"deref": deref,
|
||||
"emojify": emojify,
|
||||
|
|
@ -365,3 +366,12 @@ func deref(i any) any {
|
|||
|
||||
return vOf.Elem()
|
||||
}
|
||||
|
||||
// objectPosition formats the given focus coordinates to a
|
||||
// string suitable for use as a css object-position value.
|
||||
func objectPosition(focusX float32, focusY float32) string {
|
||||
const fmts = "%.2f"
|
||||
xPos := ((focusX / 2) + .5) * 100
|
||||
yPos := ((focusY / -2) + .5) * 100
|
||||
return fmt.Sprintf(fmts, xPos) + "%" + " " + fmt.Sprintf(fmts, yPos) + "%"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue