Add some stuff
This commit is contained in:
parent
ced6029dd8
commit
fd2d30bab6
|
@ -73,6 +73,35 @@ func profBackground(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
saveProfileBackground(ctx, 2, col)
|
||||
case "3":
|
||||
// image
|
||||
file, _, err := c.Request.FormFile("value")
|
||||
if err != nil {
|
||||
m = errorMessage{T(c, "An error occurred.")}
|
||||
return
|
||||
}
|
||||
img, _, err := image.Decode(file)
|
||||
if err != nil {
|
||||
m = errorMessage{T(c, "An error occurred.")}
|
||||
return
|
||||
}
|
||||
img = resize.Thumbnail(2496, 1404, img, resize.Bilinear)
|
||||
f, err := os.Create(fmt.Sprintf("static/profbackgrounds/%d.gif", ctx.User.ID))
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
m = errorMessage{T(c, "An error occurred.")}
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
err = jpeg.Encode(f, img, &jpeg.Options{
|
||||
Quality: 88,
|
||||
})
|
||||
if err != nil {
|
||||
m = errorMessage{T(c, "We were not able to save your profile background.")}
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
saveProfileBackground(ctx, 1, fmt.Sprintf("%d.gif?%d", ctx.User.ID, time.Now().Unix()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ Handler=/settings/profbackground
|
|||
TitleBar=Profile background
|
||||
KyutGrill=settings2.jpg
|
||||
Include=menu.html
|
||||
MinPrivileges=6
|
||||
AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.js
|
||||
*/}}
|
||||
{{ define "tpl" }}
|
||||
|
@ -21,6 +20,7 @@ AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jque
|
|||
<option value="0">{{ .T "None" }}</option>
|
||||
<option value="1"{{ if eq $type 1 }} selected{{ end }}>{{ .T "Image" }}</option>
|
||||
<option value="2"{{ if eq $type 2 }} selected{{ end }}>{{ .T "Solid colour" }}</option>
|
||||
<option value="3"{{ if eq $type 2 }} selected{{ end }}>{{ .T "GIF Image (animated)" }}</option>
|
||||
</select>
|
||||
</p>
|
||||
<div class="ui compact segment" id="image-background" style="margin: 0 auto; max-width: 400px; max-height: 700px;" data-type="1"{{ if ne $type 1 }} hidden{{ end }}>
|
||||
|
@ -67,6 +67,21 @@ AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jque
|
|||
</button>
|
||||
</p>
|
||||
</form>
|
||||
<form action="/settings/profbackground/3" method="post" enctype="multipart/form-data" class="little top margin ui form" data-type="1"{{ if ne $type 1 }} hidden{{ end }}>
|
||||
{{ $csrf }}
|
||||
<div class="ui buttons">
|
||||
<label for="file" class="ui green labeled icon button">
|
||||
<i class="file icon"></i>
|
||||
{{ .T "Open File" }}
|
||||
</label>
|
||||
{{ ieForm .Gin }}
|
||||
<button type="submit" class="ui right labeled blue icon button">
|
||||
<i class="save icon"></i>
|
||||
{{ .T "Save" }}
|
||||
</button>
|
||||
</div>
|
||||
<input type="file" id="file" style="display:none" required accept="image/*" name="value">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user