From fb7dc8590501ec0886e688208ef2319547284f50 Mon Sep 17 00:00:00 2001 From: httpjamesm Date: Wed, 28 Dec 2022 00:10:09 -0500 Subject: [PATCH] feat: adhere to image loading preference --- src/routes/question.go | 19 +++++++++++++------ templates/question.html | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/routes/question.go b/src/routes/question.go index 0a3c6e4..07efcc9 100644 --- a/src/routes/question.go +++ b/src/routes/question.go @@ -141,13 +141,20 @@ func ViewQuestion(c *gin.Context) { answers = append(answers, template.HTML(answerBodyHTML)) }) + imagePolicy := "https:" + + if c.MustGet("disable_images").(bool) { + imagePolicy = "'none'" + } + c.HTML(200, "question.html", gin.H{ - "title": questionText, - "body": template.HTML(questionBodyParentHTML), - "timestamp": questionTimestamp, - "author": questionAuthor, - "authorURL": questionAuthorURL, - "answers": answers, + "title": questionText, + "body": template.HTML(questionBodyParentHTML), + "timestamp": questionTimestamp, + "author": questionAuthor, + "authorURL": questionAuthorURL, + "answers": answers, + "imagePolicy": imagePolicy, }) } diff --git a/templates/question.html b/templates/question.html index da93ae5..7d5d7c9 100644 --- a/templates/question.html +++ b/templates/question.html @@ -7,7 +7,7 @@