Allow previewing sensitive images

A setting to not censor sensitive images if you think you're not in danger for looking at them.
This commit is contained in:
Cy 2020-05-30 21:21:31 +00:00
parent 0439440f40
commit 39f13d64fd
No known key found for this signature in database
GPG Key ID: F66D599380F88521
3 changed files with 16 additions and 2 deletions

View File

@ -50,6 +50,11 @@ class Preference(models.Model):
timezone = models.CharField( timezone = models.CharField(
max_length=80, blank=True, null=True, choices=timezones, default="UTC" max_length=80, blank=True, null=True, choices=timezones, default="UTC"
) )
preview_sensitive = models.BooleanField(
default=False,
help_text=_(
'Show preview for media marked as "sensitive"'))
no_javascript = models.BooleanField( no_javascript = models.BooleanField(
default=False, default=False,
help_text=_( help_text=_(

View File

@ -101,7 +101,7 @@
<figure class="column attachment-image"> <figure class="column attachment-image">
<a href="{{ media.url }}"> <a href="{{ media.url }}">
<noscript class="loading-lazy"> <noscript class="loading-lazy">
{% if toot.sensitive %} {% if toot.sensitive and not preferences.preview_sensitive %}
<img loading="lazy" src="{% static "images/sensitive.png" %}" <img loading="lazy" src="{% static "images/sensitive.png" %}"
{% else %} {% else %}
<img loading="lazy" src="{{ media.preview_url }}" <img loading="lazy" src="{{ media.preview_url }}"
@ -127,7 +127,7 @@
<source src="{{ media.url }}" type="video/mp4"> <source src="{{ media.url }}" type="video/mp4">
<a href="{{ media.url }}"> <a href="{{ media.url }}">
<noscript class="loading-lazy"> <noscript class="loading-lazy">
{% if toot.sensitive %} {% if toot.sensitive and not preferences.preview_sensitive %}
<img loading="lazy" src="{% static "images/sensitive.png" %}" <img loading="lazy" src="{% static "images/sensitive.png" %}"
{% else %} {% else %}
<img loading="lazy" src="{{ media.preview_url }}" <img loading="lazy" src="{{ media.preview_url }}"

View File

@ -30,6 +30,15 @@
</div> </div>
</div> </div>
<h2 class="subtitle">Options</h2>
<div class="columns">
<div class="column is-quarter">
<label class="label checkbox" for="id_preview_sensitive">
{% render_field form.preview_sensitive class+="checkbox" %}
{{ form.preview_sensitive.label }}
</label>
</div>
</div>
<h2 class="subtitle">Timeline Options</h2> <h2 class="subtitle">Timeline Options</h2>
<div class="field"> <div class="field">
<label class="label checkbox"> <label class="label checkbox">