Better handling of 3 images
This commit is contained in:
parent
80cabdd365
commit
7b4c6cf3fa
@ -4,7 +4,7 @@ WORKDIR /app/
|
|||||||
ADD go.mod go.sum ./
|
ADD go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
ADD . .
|
ADD . .
|
||||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o tweetsvg main.go
|
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o tweetsvg .
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
4
main.go
4
main.go
@ -162,8 +162,12 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if len(tweet.ExtendedEntities.Media) >= 1 {
|
if len(tweet.ExtendedEntities.Media) >= 1 {
|
||||||
ratio := float64(tweet.ExtendedEntities.Media[0].Sizes.Small.W) / 464
|
ratio := float64(tweet.ExtendedEntities.Media[0].Sizes.Small.W) / 464
|
||||||
|
if len(tweet.ExtendedEntities.Media) == 2 {
|
||||||
|
height += ((float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H) / ratio) + 5) / 2
|
||||||
|
} else {
|
||||||
height += (float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H) / ratio) + 5
|
height += (float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H) / ratio) + 5
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(tweet.ExtendedEntities.Media) > 1 {
|
if len(tweet.ExtendedEntities.Media) > 1 {
|
||||||
for i := range tweet.ExtendedEntities.Media {
|
for i := range tweet.ExtendedEntities.Media {
|
||||||
|
Loading…
Reference in New Issue
Block a user